Filip Procházka, the many-to-one associations in your test entities need to be annotated with @LazyToOne(LazyToOneOption.NO_PROXY). I believe that the extra queries you are seeing are due to Hibernate eagerly loading Product.name.previousName and Product.description.previousDescription. Without bytecode enhancement, Hibernate would have created uninitialized proxies for those associations. Because proxies are incompatible with bytecode enhancement, hibernate eagerly loads these associations. I've copied your entities into a unit test and added the @LazyToOne(LazyToOneOption.NO_PROXY). Now there is only the requested query that gets executed. You can see the modified test at https://github.com/gbadner/hibernate-core/tree/HHH-13134-test. Please give this a try and let us know if that works for you. |