2016-03-14 62 views
0

我想在屬性級別執行延遲加載。我爲Hibernate 4.3.11版本的模型類做了字節碼檢測。它工作正常,沒有任何問題。但是,當我升級我的罐子到5.1.0相同的字節碼儀器不工作。休眠字節代碼工具不適用於5.1.0版本

我google了,但沒有運氣的相同。請讓我知道是否有人有任何想法。

我的pom.xml這是工作了4.3.11版本

<插件>

  <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <executions> 
       <execution> 
        <id>hib-bytecode-optimize</id> 
        <phase>process-classes</phase> 
        <goals> 
         <goal>run</goal> 
        </goals> 
        <configuration> 
         <tasks> 
          <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask"> 
           <classpath> 
            <path refid="maven.dependency.classpath" /> 
            <path refid="maven.plugin.classpath" /> 
           </classpath> 
          </taskdef> 
          <instrument> 
           <fileset dir="${basedir}/build/classes/xxx/yyy/"> 
            <include name="*.class" /> 
           </fileset> 
          </instrument> 
          <echo>*** Hibernate bytecode optimization *** ${basedir}</echo> 
         </tasks> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

回答

0

相信ANT儀器工具已被棄用。

隨着5.0有一個級的工具,可以通過像行家被調用:

<build> 
    <plugins> 
     [...] 
     <plugin> 
      <groupId>org.hibernate.orm.tooling</groupId> 
      <artifactId>hibernate-enhance-maven-plugin</artifactId> 
      <version>$currentHibernateVersion</version> 
      <executions> 
       <execution> 
        <configuration> 
         <failOnError>true</failOnError> 
         <enableLazyInitialization>true</enableLazyInitialization> 
         <enableDirtyTracking>true</enableDirtyTracking> 
         <enableAssociationManagement>true</enableAssociationManagement> 
        </configuration> 
        <goals> 
         <goal>enhance</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     [...] 
    </plugins> 
</build>