views:

44

answers:

2

I'm trying to use hibernate to fill my jsf selectonemenu in ApplicationBean (in Liferay). The problem is that I got Initial SessionFactory creation failed problem. Before putting my functions in the applicationbean I was setting them in sessionbean and I got no error.

For now the full error

Initial SessionFactory creation failed. 
java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
A: 

The property on one of your domain classes that you've mapped as the class's version is of type string. This is not a valid type for a version. What to change it to will depend on how you are implementing versioning in your underlying database.

David M
look I'm using netbeans to autogenrate hibernate configuration and mapping file. Is there a way to find where is the error?
Feras
+1  A: 

You have very likely a VARCHAR column called VERSION somewhere and Hibernate's reverse engineering tool generates it as:

<version name="version" type="string">
  <column name="VERSION" length="20" />
</version>

instead of:

<property name="version" type="string">
  <column name="VERSION" length="20" />
</property>

The former is wrong. First, I think that this is not what you want. Second, a string is not allowed for a version field as mentioned in the chapter 5.1.9. Version (optional):

Version numbers can be of Hibernate type long, integer, short, timestamp or calendar.

This problem has been somehow reported in HHH-3002 (actually, it should be assigned to Hibernate Tools, not Hibernate Core) and I see two ways to solve it. Either

  • fix the mapping manually
  • rename the column to something else.
Pascal Thivent