-->
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: Select For Update in JPA
PostPosted: Thu Jul 13, 2006 10:27 am 
Newbie

Joined: Thu Jul 13, 2006 10:13 am
Posts: 1
Hi All,

In Hibernate Session there is a method get(Class klass, Serializable id, LockMode lockMode). Why is the JPA EntityManager missing an analogous method?

For example, in order to perform a "select for update" in JPA it is needed to get an entity first and then lock it:

Employee emp = em.find(Employee.class, 123L);
em.lock(emp, LockModeType.READ);

That will result in 2 selects:

1. select ... from Employee
2. select ... from Employee for update.

In Hibernate, however, I could just write:

session.get(Employee.class, 123L, LockMode.UPGRADE);

which will just run a "select for update" and return an entity.

So, my question is whether it is possible to get an entity in JPA and perform a "select for update" at the same time? Or am I missing somethong.


Cheers,

Dimitrio


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 16, 2006 1:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
interesting.
This is not supported out of the box with JPA.
The reason is that JPA does not support the select for update thing, it's left to the implementation. What is supported is some kind of transaction isolation level guaranty (which is only mandatory on versioned entities).

_________________
Emmanuel


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.