We're updating the issue view to help you get more done. 

Version increment not triggered on @OneToOne property modification having inverse owner

Description

In the revised "Java Persistence with Hibernate" book by Christian Bauer and Gavin King on page 464
there's written following about versioning:

"If you use Hibernate as JPA provider ... every value-typed property modification .. triggers a version increment."

Now I saw that Version increment indeed is not triggered on @OneToOne properties having an inverse owner (= mappedBy setted).
This allows several concurrent transactions to set the association from same object towards different targets without having a OptimistickLockException at commit.
This violates the ToOne policy! (Hibernate detects the inconsistency later when loading the property from database:
org.hibernate.HibernateException: More than one row with the given identifier was found)

Please see attached junit-testcase for reproducing the problem.

regards
Guenther Demetz

Environment

Hibernate 3.3.1.GA , Microsoft SQL Server

Status

Assignee

Gail Badner

Reporter

Guenther Demetz

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Minor