we shortly updated our hibernate and hibernate envers versions and experienced an (I believe) unwanted behaviour:
Assume the following Integration Test using Spring Data Repositories:
As the id of the "OtherEntity" reference is held in the proxy, Envers should be able to fill it without additional queries.
Envers fires a SELECT query to retrieve the "OtherEntity" reference from the database.
This is bad for various reasons in my opinion:
1. it causes unnecessary work on the database due to the fact, that there are multiple additional queries fired which are not needed at all
2. it makes EntityManager.getReference() method totally useless. This method is great for getting a reference without the need to load the object from the Database to store it in a relationship. If there is a select now every time I save an object, this usecase is totally gone
3. if there is no transaction going on at the point of saving the entity, it is even worse because a LayzInitializationException is thrown in this case.
I tested with all versions from 5.4.10 (which we previously worked with) to the current 5.4.20. The described behaviour shows up in 5.4.11 and persists from this point on
I looked through the JIRA issues related to hibernate-envers 5.4.11 and found https://hibernate.atlassian.net/browse/HHH-13760 which could be related, but I am not sure about this
I choosed major priority because I see this as a breaking change introduced in a minor version which should probably not occur and because it prevents us from upgrading.
If you see a possibility to workaround this issue I would be really happy to hear about it.
Spring Boot 2.3, Hibernate-Envers 5.4.11.Final (and higher)