Bytecode enhancement for Hibernate 5.3.7

505 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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!