Hibernate3 Maven Plugin を使用して、データベースからドメイン/モデル POJO の生成を実装しています。理論的根拠は、開発者がさらに作業を開始する前に、データベースに対する DBA の更新がモデル層に自動的にマップされるようにすることです。そのため、Hibernate CFG が生成されてから POJO が生成される必要があります。また、古い実装は hbm.xml の代わりに注釈を使用する開発者で構成されていたため、生成されたクラスに注釈を付ける必要があります。これは、Hibernate Maven Plugin の POM からの抜粋です。
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implementation>jdbcconfiguration</implementation>
</component>
</components>
<componentProperties>
<ejb3>true</ejb3>
<packagename>com.dss.domain</packagename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<inherited>false</inherited>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
<componentProperties>
<ejb3>true</ejb3>
<packagename>com.dss.domain</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.16</version>
</dependency>
</dependencies>
</plugin>
</plugins>
cfg.xml ファイルが生成されていることがわかります。しかし、hbm2java はメッセージで失敗します
プロジェクト dss-domain で目標 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java (hbm2java) を実行できませんでした: 目標 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2java の実行 hbm2java が失敗しました: 実行できません構成で < mapping class="com.dss.domain.Foo" / > として宣言されたクラスをロードするには: -> [ヘルプ 1]
後の段階で、これらすべてを現在の JPA 実装に移動する必要があるため、別の質問は、コンポーネント プロパティで jpaconfiguration に切り替える必要があるかどうかです。
また、依存関係を古いプロジェクト (Hibernate 3.6.6-FINAL) で最近 uopdated されたものに更新すると、これらのどれもまったく機能しないようです。しかし、それはここに投稿された別の質問です。
ポインタや完全な解決策は大歓迎です;-)