| Using the Javassist bytecode enhancer ( mvn compile -Dhibernate.bytecode.provide=javassit ) the code fails to compile with the following message:
[ERROR] Failed to execute goal org.hibernate.orm.tooling:hibernate-enhance-maven-plugin:5.3.10.Final:enhance (default) on project spring-petclinic:
Unable to enhance class: Pet.class:
Unable to enhance persistent attribute [org.springframework.samples.petclinic.owner.Pet:visits]:
Could not enhance entity class [org.springframework.samples.petclinic.owner.Pet] to add field writer method [$$_hibernate_write_visits]:
[source error] $$_hibernate_write_petId(org.springframework.samples.petclinic.owner.Pet) not found in org.springframework.samples.petclinic.visit.Visit -> [Help 1]
For ByteBuddy enhancer, it does not fail to compile even if the types do not match. Anyway, both implementations should type check and skip bi-directional association management, like when the field is not found. |