I am developing a database connector in order to retrieve data from a Oracle database. I have used the Hibernate tool included as a plug-in in Eclipse for the generation of the Hibernate mapping files because I have a lot of classes and tables to map. However, when I run the application, I have just get the following Exception:
java.lang.ClassCastException: org.hibernate.type.StringType cannot be cast to org.hibernate.type.VersionType
at org.hibernate.tuple.PropertyFactory.buildVersionProperty(PropertyFactory.java:107)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:181)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:485)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:133)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:286)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1845)
at eu.cartif.dwhconn.database.DBManager.checkDWHStatus(DBManager.java:57)
at eu.cartif.dwhconn.database.DBManager.main(DBManager.java:24)
I think the problem could be the type of the property of the hbm file:
<hibernate-mapping>
<class name="eu.cartif.dwhconn.database.Ifcactorrole" table="IFCACTORROLE">
<id name="role" type="string">
<column name="ROLE" length="50" />
<generator class="assigned" />
</id>
<property name="userdefinedrole" type="string">
<column name="USERDEFINEDROLE" />
</property>
<property name="description" type="string">
<column name="DESCRIPTION" length="3000" />
</property>
<set name="ifcpersons" table="IFCPERSON" inverse="true" lazy="true" fetch="select">
<key>
<column name="ROLES" length="50" />
</key>
<one-to-many class="eu.cartif.dwhconn.database.Ifcperson" />
</set>
<set name="ifcpersonandorganizations" table="IFCPERSONANDORGANIZATION" inverse="true" lazy="true" fetch="select">
<key>
<column name="ROLES" length="50" />
</key>
<one-to-many class="eu.cartif.dwhconn.database.Ifcpersonandorganization" />
</set>
</class>
</hibernate-mapping>
However, I am not sure about it and I would not like to change all the types in all the hbms if that is not the solution. Anyone could help me, please.
Thank you very much in advance, May you have a nice day
In my case, I generated entity from DB and some entities column name has "version". Generator for this names add "@Version" annotation, but this column type is String - for @Version annotation unacceptable
This types of problem occurs
if there are column name as "version" of "VARCHAR" (string) type in any table, means in hibernate "property" becomes "version" and "type" becomes "string", like-
in .hbm.xml file
<version name="xyz" type="string">
<column name="xyz" length="30" not-null="true" />
</version>
if there are any missing getter or setter method for a particular attribute.
if there are mismatch between .hbm.xml file and POJO class file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With