2011-08-19 27 views
3

我能在我的pom.xml具有這種基於Java的JPA-entites的運行Hibernate的jpamodelgen:如何在斯卡拉實體運行Hibernate的JPAMetaModelEntityProcessor靜態模型生成

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-jpamodelgen</artifactId> 
    <version>1.1.1.Final</version> 
</dependency> 

但失敗的書面實體當然在斯卡拉。我一直在努力,「手動」使用有我的pom.xml這個樣子行家處理器的插件生成的元模型:

<plugin> 
    <groupId>org.bsc.maven</groupId> 
    <artifactId>maven-processor-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>process</id> 
      <goals> 
       <goal>process</goal> 
      </goals> 
      <phase>generate-sources</phase> 
      <configuration> 
       <processors> 
        <!-- list of processors to use --> 
        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> 
       </processors> 
       <!-- source output directory --> 
       <outputDirectory>target/metamodel</outputDirectory> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>build-helper-maven-plugin</artifactId> 
    <version>1.3</version> 
    <executions> 
     <execution> 
      <id>add-source</id> 
      <phase>generate-sources</phase> 
      <goals> 
       <goal>add-source</goal> 
      </goals> 
      <configuration> 
       <sources> 
        <source>target/metamodel</source> 
       </sources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

但沒有任何反應。

任何人都成功地從JPA實體編寫的斯卡拉JPA元模型?

謝謝。

回答

1

不要認爲這是可能的,因爲元模型生成器在javac中作爲可插入註釋處理器(http://jcp.org/en/jsr/detail?id=269)運行,即在Java源中。

然而,Javac不會理解你的Scala源代碼和Scalac(據我所知)並不支持JSR 269接口。