Hibernate Bytecode Enhancement for a Groovy Project

I’m attempting to use the hibernate plugin in my Spring Boot groovy project. I added the following configuration to my build.gradle

buildscript {
	ext {
		hibernateVersion = '5.3.7.Final'
	}
	dependencies {
		classpath("org.hibernate:hibernate-gradle-plugin:${hibernateVersion}")
	}
}
apply plugin: 'org.hibernate.orm'

hibernate {
	enhance {
		enableLazyInitialization=true
		enableDirtyTracking=true
	}
}

But I am unable to use bytecode enhanced features like lazy loading properties. I look at my decompiled groovy (I’m using @CompileStatic) and I see no bytecode enhancement.

Inside of the plugin, the enhancement task executes this line:

final Task compileTask = project.getTasks().findByName( sourceSet.getCompileJavaTaskName() );

which will always return CompileJava which will never work for me since I use CompileGroovy. Are there any known work arounds for this?

1 Like