我正在开发一个数据库连接器,以便从 Oracle 数据库中检索数据。我使用 Eclipse 中作为插件包含的 Hibernate 工具来生成 Hibernate 映射文件,因为我有很多类和表要映射。但是,当我运行应用程序时,我刚刚得到以下异常:
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)
我认为问题可能是 hbm 文件的属性类型:
<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>
但是,我不确定,如果这不是解决方案,我不想更改所有 hbms 中的所有类型。任何人都可以帮助我,请。
非常感谢您,祝您有美好的一天