Bug 1121672

Summary: Version is not incremented when a bidirectional one-to-one association changes
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Gary Hu <ghu>
Component: HibernateAssignee: Gail Badner <gbadner>
Status: CLOSED NOTABUG QA Contact: Martin Simka <msimka>
Severity: unspecified Docs Contact: Russell Dickenson <rdickens>
Priority: unspecified    
Version: TBD EAP 6CC: fgavrilo, gbadner, msimka, smarlow
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-07-28 18:11:09 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Gary Hu 2014-07-21 14:41:08 UTC
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

Comment 1 Gail Badner 2014-07-21 21:05:06 UTC
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.

Comment 2 Fedor Gavrilov 2014-07-25 07:44:39 UTC
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.

Comment 3 Fedor Gavrilov 2014-07-25 07:49:34 UTC
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?

Comment 4 Gail Badner 2014-07-28 18:11:09 UTC
HHH-4289 has been rejected. This is not a bug.