0

Я использую Maven плагин, чтобы генерировать POJO и дао:Пользовательские зимуют инструмент экспортер

<groupId>org.codehaus.mojo</groupId> 
<artifactId>hibernate3-maven-plugin</artifactId> 
<version>2.2</version> 
<executions> 
    <execution> 
     <phase>generate-sources</phase> 
     <goals> 
      <goal>hbm2java</goal> 
      <goal>hbm2dao</goal> 
      <goal>hbm2ddl</goal> 
     </goals> 
    </execution> 
</executions> 
<configuration> 
    <components> 
     <component> 
      <name>hbm2java</name> 
      <implementation>configuration</implementation> 
      <outputDirectory>src/main/java</outputDirectory> 
     </component> 
     <component> 
      <name>hbm2dao</name> 
      <implementation>configuration</implementation> 
      <outputDirectory>src/main/java</outputDirectory> 
     </component> 
     <component> 
      <name>hbm2ddl</name> 
      <implementation>configuration</implementation> 
      <outputDirectory>src/main/resources/sql</outputDirectory> 
     </component> 
    </components> 
    <componentProperties> 
     <jdk5>true</jdk5> 
     <format>true</format> 
     <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile> 

     <drop>true</drop> 
     <create>true</create> 
     <outputfilename>init.sql</outputfilename> 
     <templatepath>src/main/resources/templateftl</templatepath> 

    </componentProperties> 
</configuration> 

ужасно Дао и POJO генерируются в одном пакете

В Hibernate инструментов он HARDCODED

DAOExporter : setFilePattern("{package-name}/{class-name}Home.java"); 
POJOExporter : setFilePattern("{package-name}/{class-name}.java"); 

Я нахожу это крайне уродливым, и я хотел бы иметь pojo и dao в разных упаковках, а также не суффиксы Dao от «Home», а просто «Dao»

Знаете ли вы, есть ли способ предоставить пользовательскую реализацию Exporter или настроить что-то в подключаемом устройстве для достижения этого?

благодаря

ответ

0

Finaly Я использовал JD-GUI для декомпиляции и прочитать код плагина, и мне удалось сделать это работает в 2 раза плагин с целью hbmtemplate каждый раз с использованием другого шаблона: один для лица один для дао.

Я узнал, что пользовательский экспортер можно использовать, указав его в классе exporterclass. maven плагины не хватает короля xsd ...

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>hibernate3-maven-plugin</artifactId> 
    <version>2.2</version> 
    <executions> 
     <execution> 
      <phase>generate-sources</phase> 
      <id>genpojo</id> 
      <goals> 
       <goal>hbmtemplate</goal> 
       <goal>hbm2ddl</goal> 
      </goals> 
      <configuration> 
      <components> 
       <component> 
        <name>hbmtemplate</name> 
        <implementation>configuration</implementation> 
        <outputDirectory>src/main/java</outputDirectory> 
       </component>       
       <component> 
        <name>hbm2ddl</name> 
        <implementation>configuration</implementation> 
        <outputDirectory>src/main/resources/sql</outputDirectory> 
       </component> 
      </components> 
      <componentProperties> 
       <jdk5>true</jdk5> 
       <format>true</format> 
       <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile> 
       <drop>true</drop> 
       <create>true</create> 
       <outputfilename>init.sql</outputfilename> 
       <templatepath>src/main/resources/templateftl</templatepath> 
       <filepattern>{package-name}/pojogen/{class-name}.java</filepattern> 
       <template>pojo/Pojo.ftl</template> 
      </componentProperties> 
     </configuration> 
     </execution> 
     <execution> 
      <phase>generate-sources</phase> 
      <id>gendao</id> 
      <goals>       
       <goal>hbmtemplate</goal> 
      </goals> 
      <configuration> 
      <components>       
       <component> 
        <name>hbmtemplate</name> 
        <implementation>configuration</implementation> 
        <outputDirectory>src/main/java</outputDirectory> 
       </component> 
      </components> 
      <componentProperties> 
       <jdk5>true</jdk5> 
       <format>true</format> 
       <configurationfile>src/main/resources/hibernate/hibernate.cfg.xml</configurationfile> 
       <drop>true</drop> 
       <create>true</create> 
       <templatepath>src/main/resources/templateftl</templatepath> 
       <!-- <exporterclass>com.db.exporter.MyDAOExporter</exporterclass>--> 
       <filepattern>{package-name}/daogen/{class-name}Dao.java</filepattern> 
       <template>dao/daohome.ftl</template> 
      </componentProperties> 
     </configuration> 
     </execution> 
    </executions> 

</plugin>