hbm2java生成时修改pojos文件名最简单的方法是什么
我通过maven使用hbm2java生成pojos,它会生成Table.java等文件,但我想要的是AbstractTable.java
有没有一种简单的方法可以做到这一点?
来自我的 pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2hbmxml</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2hbmxml</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
<namingstrategy>uk.co.company.product.hibernate.CustomNamingStrategy</namingstrategy>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.3.GA</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
</dependencies>
</plugin>
I'm using hbm2java via maven to generate pojos, it will produce files such as Table.java, but what I want is AbstractTable.java
Is there an easy way to do this?
From my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2hbmxml</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2hbmxml</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2hbmxml</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<outputDirectory>src/main</outputDirectory>
</component>
</components>
<componentProperties>
<revengfile>src/conf/reveng.xml</revengfile>
<propertyfile>src/conf/hibernate.properties</propertyfile>
<templatepath>src/conf/hibernate-templates</templatepath>
<jdk5>true</jdk5>
<namingstrategy>uk.co.company.product.hibernate.CustomNamingStrategy</namingstrategy>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-tools</artifactId>
<version>3.2.3.GA</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
</dependency>
</dependencies>
</plugin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自定义模板似乎确实是实现这一目标的方法。
最后,我从 jar 中提取了 pojo 模板文件,以便我可以修改它们,然后在 pojo 模板和 filepattern 上使用 hbmtemplate 来执行此操作。有点烦人的是你不能只使用 hbm2pojo 的文件模式。
如果有人感兴趣的话,这是我的 pom:
custom templates do seem to be the way to go to achieve this.
In the end I extracted the pojo template files out of the jar so I could modify them and then used hbmtemplate on the pojo templates and filepattern to do this. It's a bit annoying that you can't just use the filepattern with hbm2pojo.
Here's my pom if anyone's interested: