-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: JPA and pessimistic lock @OneToMany question
PostPosted: Mon Oct 15, 2007 5:10 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 3:22 am
Posts: 69
I was wondering how can I cascade a pessimistic lock across all child entities in a onetomany where the child entities reside in other tables and it is unidirectional?

I'm operating within a JEE5 environment so would like to make use of standard JPA EM calls if possible so at the moment I'm doing something like this.

Code:
em.lock(
            em.getReference( x.class, x.getID() ),
            LockModeType.WRITE );


Now assuming x has two unidirectional @OneToMany linked by a jointable does doing this cascade a pessimistic lock across all of the childen?

Thanks, S.D.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 15, 2007 7:06 pm 
Regular
Regular

Joined: Fri Oct 05, 2007 3:22 am
Posts: 69
Never mind, I found this when looking at org.hibernate.annotations.CascadeType.LOCK

This option cascades the lock() operation to associated instances, reattaching
them to the persistence context if the objects are detached. Note that the
LockMode isn’t cascaded; Hibernate assumes that you don’t want pessimistic
locks on associated objects—for example, because a pessimistic lock on the
root object is good enough to avoid concurrent modification.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.