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.

-- 
st...@hibernate.org
http://hibernate.org
_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to