2011-03-18 67 views

回答

0

的休眠Maven插件不會自動做的,你需要的,如果你想使用@IdClass手動更新的類。

+0

咋樣maven呢?有可能嗎? – Ozgur 2011-03-18 18:02:47

+0

我不知道:(。我不使用逆向工程工具,否則我不能將實體更改爲域模型(例如我無法添加方法)。我建議您創建文件第一次,然後定製他們做你想做的事 – Augusto 2011-03-18 18:06:13

+0

你說的對,我剛剛檢出了hibernate工具的源代碼,這個功能在模板文件中不存在,我現在有一個很可怕的失望 – Ozgur 2011-03-18 22:59:41

0

我還沒有試過。但從我一直在使用Hibernate reverseengineering工具的工作中,我認爲應該可以使用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_maphttp://docs.jboss.org/tools/3.1.0.GA/en/hibernatetools/html_single/index.html#d0e5869)。

如前所述,我沒有嘗試過。

由於各種其他原因,我放棄了使用逆向工程。一個問題是,hibernate工具不符合Hibernate 3.5及更高版本。此外,Maven插件是第三方的,並且使用比現有的一般Hibernate工具更早的版本。所以我也遇到了這種情況,我不得不從Maven打電話給Ant來做逆向工程。

+0

是的,你是對的,可以使用reveng文件,但是我無法理解type_map部分,據我所知它可以用來將jdbc_type映射到java類型,我的第二個問題是關於ant c onfiguration。如果你不介意,你會分享嗎? – Ozgur 2011-03-21 20:13:16

+0

hibernate文檔鏈接不再可用。有沒有人有更新鏈接? – Jason 2014-01-19 18:59:07