2010-11-19 5 views
2

hbm2java 생성시 POJO를의 파일 이름을 수정하는 가장 쉬운 방법은 무엇입니까, 그러한 Table.java 같은 파일을 생성,하지만 내가 원하는 내가 POJO를 생성하는 받는다는 통해 hbm2java를 사용하고

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> 

답변

2

사용자 정의 템플릿은이를 달성하기 위해 길을 가야하는 것 같다 않습니다. 결국 pojo 템플릿 파일을 jar 파일에서 추출하여 수정 한 다음 pojo 템플릿과 filepattern에서 hbmtemplate을 사용하여이 작업을 수행 할 수있었습니다. hbm2pojo로 파일 패턴을 사용할 수 없다는 것은 약간 짜증납니다. 사람이 관심이 있다면

여기 내 치어입니다 :

  <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> 
관련 문제