0

我们正在将一个大型数据库从一个 DBMS 转换为另一个。为此,我们主要使用 JDBC,但也混入了一些 Hibernate 调用。到目前为止,数据库的一小部分需要 7 个小时才能迁移。为了缓解这种情况,我们决定可以同时迁移数据库的不同部分。我们重写了迁移例程以使用线程。在解决了 Java 堆空间问题并确保我们在每个线程中都有单独的 JDBC 和 Hibernate 会话之后,我们发现自己遇到了最后一个问题:我们得到了 Unknown entity: exceptions 无处不在。我们正在创建一个 SchemaExport 并在任何迁移线程开始之前执行它。我们缺少什么?

4

1 回答 1

1

Apparently, Unknown entity is an exception which happens when hibernate doesn't know about the class which is referenced in the exception. e.g., for the Myclass class:

Exception in thread "main" org.hibernate.MappingException: Unknown entity: data.Myclass

You need to have a <classname>.hbm.xml file, which corresponds to a hibernate mapping, in order for each class that must be known by hibernate, and also have these files referenced as resources in the main configuration file of hibernate. in hibernate.cfg.xml, this is the line to let hibernate know about the class Myclass:

<mapping resource="Myclass.hbm.xml" />
于 2012-10-29T22:23:51.603 回答