简体   繁体   中英

Bytecode enhancement for Hibernate 5.3.7

I used to instrument my classes in Hibernate 4.x with an ant target:

<target name="instrument" depends="compile">
        <taskdef name="enhance" classname="org.hibernate.tool.enhance.EnhancementTask">
            <classpath refid="extended.classpath"/>
            <classpath path="${classbin.dir}"/>
        </taskdef>

        <instrument verbose="true">
            <fileset dir="${TARGETROOT}/home/WEB-INF/classes">
                <include name="org/zfin/publication/Publication.class"/>
            </fileset>
        </instrument>
    </target>

But this stopped working when I upgraded to Hibernate 5.3.7. What is the proper way to do this in ant? Note, I do not use Maven.

I tried this change

    <target name="instrument" depends="compile">
        <taskdef name="enhance" classname="org.hibernate.tool.enhance.EnhancementTask">
            <classpath refid="extended.classpath"/>
            <classpath path="${classbin.dir}"/>
        </taskdef>

        <enhance base="${classbin.dir}" dir="${classbin.dir}/org/zfin/publication" failOnError="false" enableLazyInitialization="true"
                 enableDirtyTracking="false"
                 enableAssociationManagement="false"
                 enableExtendedEnhancement="false">
        </enhance>
    </target>

but it outputed [enhance] Unable to enhance class: Publication.class

indicating that it is not working. It enhanced some classes in that directory but not the one I needed.

I figured out that Hibernate 5.3.7 is using byte-buddy 1.8.17. When upgrading to byte buddy 1.10.18 it all worked!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM