我正在尝试将 jpa2 功能 @ElementCollection 用于我的实体中的字符串列表。我正在使用 hibernate3-maven-plugin 来执行 hbm2ddl 任务。
但是,插件使用的 hibernate 工具版本似乎不知道如何处理@ElementCollection 注释,任何人都可以指点我需要使用什么版本的 hibernate 工具,这样情况就不是这样了。是否应该只指定正确版本的 hibernate 工具?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-603.jdbc4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.4.GA</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
[INFO] Trace org.hibernate.MappingException: Could not determine type for: java.util.List, at table: mystuff, for columns: [org.hibernate.mapping.Column(stuffs)]
谢谢
最佳答案
我认为您的插件版本不匹配。 hibernate3-maven-plugin 依赖于 Hibernate 3.3.1.GA。
您可以尝试在 hibernate3-maven-plugin 上忽略它并手动获取正确的版本(3.5.3 Final 可能有效)。
也许在字段上设置注释而不是 setter 也可能有帮助。
关于java - 在 hibernate 工具 hbm2ddl 中支持 @ElementCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4185809/