[hibernate-dev] Hibernate ORM 4.1.1 release - Undocumented behavior change in Optimistic Versioning ?

Steve Ebersole steve at hibernate.org
Fri Mar 9 09:17:14 EST 2012


Indexed collections (maps and lists) should always be the owning side 
of bi-directional associations for the exact reason you mention.  Not 
sure if annotations actually enforces that or whether JPA even allows 
us to enforce that.

On Fri 09 Mar 2012 07:53:20 AM CST, Demetz, Guenther wrote:
> Thank you Steve,
>
> anyway in this context
> I strongly recommend all Hibernate-Users to force version increment explicitly on such OneToMany relations when the mapped collection is a map!
> Otherwise, unless implementing some pessimistick locking, 2 concurrent transactions will be able to insert an object in the map, each indipendently from the other, using the same key value, without getting any exception at flush or commit time.
> This leads finally in having 2 records persisted on database whilst in hibernate (due the constraints of the map) on successive accesses you always will see just one. This is quite dangereous.
>
> regards
> G.D.

-- 
steve at hibernate.org
http://hibernate.org



More information about the hibernate-dev mailing list