【发布时间】:2011-07-23 07:55:24
【问题描述】:
我正在尝试使用 hibernate3-maven-plugin 的 hbm2ddl goal 从一组 JPA 注释类生成 DDL。我在 pom.xml 中配置了以下内容
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hibernate-create-schema</id>
<phase>process-classes</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
</component>
</components>
<componentProperties>
<jdk5>true</jdk5>
<persistenceunit>bm-domain</persistenceunit>
<outputfilename>create.sql</outputfilename>
<drop>false</drop>
<create>true</create>
<export>false</export>
<format>true</format>
</componentProperties>
</configuration>
</execution>
</executions>
</plugin>
我的 persistence.xml 仅包含以下内容:
<persistence-unit name="bm-domain" transaction-type="RESOURCE_LOCAL">
</persistence-unit>
我已经将一个 database.properties 文件添加到指定的类路径中:
hibernate.dialect=org.hibernate.dialect.MySQLDialect
当我运行 mvn install 时出现错误:
org.hibernate.MappingException: 可以 不确定类型:java.util.Set, 在表:用户,列:[org.hibernate.mapping.Column(compatibleAnnualEarnings)]
这似乎是指User类的以下属性
Set<AnnualEarnings> compatibleAnnualEarnings;
@Enumerated(EnumType.STRING)
AnnualEarnings annualEarnings;
AnnualEarnings 类位于 User 类的包的子包中,其定义如下:
public enum AnnualEarnings implements Serializable{
GROUP_1, GROUP_2, GROUP_3, GROUP_4, GROUP_5, GROUP_6, GROUP_7;
}
【问题讨论】:
标签: java hibernate maven-2 jpa