I have an entity mapped as:
ID of Address.Version is composite of Address entity + a numeric version number (not related to `@javax.persistence.Version`).
ID of Address is numeric ID.
ID of Shipment numeric ID.
and when an update transaction is about to commit, I get:
I cannot be 100% sure but I think this started to happen when we moved to both origin and destination addresses being `optional=true`
JDK 11, Mac OS X
I’m experiencing an eerily similar issue with both 5.3.9 and 5.3.13, which was /not/ experienced with 5.1.
Hibernate itself has no issue inserting new rows:
Now, Envers enters the scene as it attempts to audit. Revision is created:
Then... oddity when trying to create an audit entry for the above entity change (new/insert):
Updates to entities do not have this issue:
We’re not experiencing this on all audited entities.
For the record, the annotations are as follows (abbreviated):
(sorry for the long comment)
Well! I’m “glad” to see I’m not the only one having this kind of issue, if that serves to raise more attention on the issue…
A quick update, I believe I have a fix in the works for this. The reason I believed this failed is because when mapped as LAZY, the ToOneIdMapper wasn't taking into account that the associated entity object needed to be resolved from the proxy to its non-proxy counter-part. I need to run some tests and validate this doesn't break anything and if that's the case, you should expect to see a PR shortly.
Thanks guys for the wonderful feedback and tests as this helped diagnose the problem relatively easily.
Can either you give the PR changes in https://github.com/hibernate/hibernate-orm/pull/3170 a try and let me know if that truly solves your issues? The test case provided by Francisco passes, but would like to be sure we've covered all bases.
I didn’t see the notifications about the issue, I’m sorry. I checked my code and works well with latest changes, so thank you for fixing.