首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在hbm2java生成过程中修改pojos文件名最简单的方法是什么

在hbm2java生成过程中修改pojos文件名最简单的方法是什么
EN

Stack Overflow用户
提问于 2010-11-19 23:19:58
回答 1查看 1.9K关注 0票数 2

我通过maven使用hbm2java来生成pojos,它将生成诸如Table.java之类的文件,但我想要的是AbstractTable.java

有什么简单的方法可以做到这一点吗?

在我的pom.xml上:

代码语言:javascript
复制
     <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-11-24 00:12:54

自定义模板似乎是实现这一目标的方法。最后,我将pojo模板文件从jar中提取出来,以便对其进行修改,然后对pojo模板和filepattern使用hbmtemplate来完成此操作。你不能只在hbm2pojo中使用filepattern,这有点烦人。

如果任何人感兴趣,这是我的pom:

代码语言:javascript
复制
            <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>hbmtemplate0</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbmtemplate</goal>
                    </goals>
                    <configuration>
                        <components>
                            <component>
                                <name>hbmtemplate</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>
                            <ejb3>false</ejb3>
                            <filepattern>{package-name}/Abstract{class-name}.java</filepattern>
                            <templateprefix>pojo/</templateprefix>
                            <destdir>src/main</destdir>
                            <template>pojo/Pojo.ftl</template>
                        </componentProperties>
                    </configuration>
                </execution>
                <execution>
                    <id>hbmtemplate1</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbmtemplate</goal>
                    </goals>
                    <configuration>
                        <components>
                            <component>
                                <name>hbmtemplate</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>
                            <ejb3>false</ejb3>
                            <filepattern>{package-name}/{class-name}.java</filepattern>
                            <templateprefix>pojoImpl/</templateprefix>
                            <destdir>src/main</destdir>
                            <template>pojoImpl/PojoImpl.ftl</template>
                        </componentProperties>
                    </configuration>
                </execution>
                <execution>
                    <id>hbmtemplate2</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbmtemplate</goal>
                    </goals>
                    <configuration>
                        <components>
                            <component>
                                <name>hbmtemplate</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>
                            <ejb3>false</ejb3>
                            <filepattern>{package-name}/Abstract{class-name}DAO.java</filepattern>
                            <templateprefix>dao/</templateprefix>
                            <destdir>src/main</destdir>
                            <template>dao/daohome.ftl</template>
                            <sessionFactoryName>sessionFactoryName.goes.here</sessionFactoryName>
                        </componentProperties>
                    </configuration>
                </execution>
                <execution>
                    <id>hbmtemplate3</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>hbmtemplate</goal>
                    </goals>
                    <configuration>
                        <components>
                            <component>
                                <name>hbmtemplate</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>
                            <ejb3>false</ejb3>
                            <filepattern>{package-name}/{class-name}DAO.java</filepattern>
                            <templateprefix>daoImpl/</templateprefix>
                            <destdir>src/main</destdir>
                            <template>daoImpl/daoImpl.ftl</template>
                            <sessionFactoryName>sessionFactoryName.goes.here</sessionFactoryName>
                        </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>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4226379

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档