Hibernate Initial Initialization Failure

I am trying to use hibernate to populate jsf selectonemenu in ApplicationBean (in Liferay). The problem is that I got the initial SessionFactory creation problem. Before putting my functions in applicationbean, I installed them in sessionbean and I had no errors.

Now a complete mistake

 Initial SessionFactory creation failed. java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType 
+4
source share
2 answers

You very likely have a VARCHAR column named VERSION somewhere, and the Hibernate reverse engineering tool generates it as:

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

instead:

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

The first is wrong. Firstly, I think this is not what you want. Secondly, the string is not allowed for the version field, as described in chapter 5.1.9. Version (optional) :

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

This problem was somehow reported in HHH-3002 (in fact, it should be assigned to Hibernate Tools, not Hibernate Core), and I see two ways to solve it. Or

  • fix display manually
  • rename the column to another.
+8
source

The property on one of your domain classes that you displayed as the version of the class has a type string. This is not a valid type for version. What will change it will depend on how you implement version control in your base database.

+1
source

Source: https://habr.com/ru/post/1312862/


All Articles