我使用hbm2java (hibernate3-maven-plugin)来生成实体。
如何将自动生成的@EmbeddedId切换为@IdClass?
谢谢
发布于 2011-03-19 00:59:17
hibernate maven插件不会自动更新,如果你想使用@IdClass,你需要手动更新你的类。
发布于 2011-03-22 00:42:31
我没有试着跟上。但从我使用Hibernate逆向工程工具的经验来看,我认为使用reveng.xml文件应该是可行的。在你的pom文件中。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<components>
<component>
<name>hbm2java</name>
</component>
</components>
<componentProperties>
<revengfile>/src/main/resources/reveng/model.reveng.xml</revengfile>
</componentProperties>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>hbm2java</goal>
</goals>
</execution>
</executions>
并在reveng.xml中指定到IdClass的类型映射(请参阅Hibernate工具文档http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html_single/index.html#type_map或http://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html_single/index.html#d0e5869)。
如上所述,我还没有尝试过。
出于其他各种原因,我放弃了使用逆向工程。其中一个问题是hibernate工具与Hibernate 3.5及更高版本不兼容。此外,Maven插件是第三方的,使用的Hibernate工具版本比一般可用的旧版本。所以我也遇到了这样的情况,我不得不从Maven调用ant来进行反向工程。
https://stackoverflow.com/questions/5354205
复制相似问题