We have two entities which share a bidirectional one-to-one association. However, when the association is changed, the version (for optimistic-locking) is not updated on one side of the association. A JIRA issue has been already raised. [1] A pull request containing a unit test that could reproduce the issue has been already created [2]. The customer is expecting the fix could be included in Hibernate 4.3.x which contains some other fixes they've already applied. [1] https://hibernate.atlassian.net/browse/HHH-9005 [2] https://github.com/hibernate/hibernate-orm/pull/701
In JPA 2.1. spec, section 3.4.2 Version Attributes: "All non-relationship fields and properties and all relationships owned by the entity are included in version checks". This is expected behavior because the entity does not own the association that was modified.
Hello Gail! And thank you for the link. Personally, I am not a fan of making associations bidirectional in any case. Though, it seems to me that specification is somewhat vague: I think we still can add relationship fields into version checks without violating the spec, can't we? It might be handy for the cases like this. Though, if you think this is a bad idea - could you please explain it to me in more detail so that I could have an argument with the customer? Thanks.
P.SP: Just saw yor latest comment on https://hibernate.atlassian.net/browse/HHH-4289 and I'm kinda lost now. It seems to me that customer wants this fix for 1-to-1 association, so I suppose this is still unresolved, isn't it?
HHH-4289 has been rejected. This is not a bug.