upgrade « Transaction « JPA Q&A





1. Two queries instead of one, when using LockOption.UPGRADE    stackoverflow.com

I have two entities with one-directional OneToOne relationship. EAGER fetch type is specified. When I load parent entity by id, one sql inner join query is executed. This is right behavior. But when ...

2. LockMode.UPGRADE in Hibernate    coderanch.com

Upgrade mode works for Select for Update.Which means we select the data with some query and we can lock that for the following update. My question is how long the records are being locked.. If i update some of the objects then other records will still stay locked. I will be updating only certain records not all of the records based ...

3. can't "upgrade" to LockMode.OPTIMISTIC    forum.hibernate.org

Hibernate 3.5 has new LockModes, two related to optimistic locks, LockMode.OPTIMISTIC and LockMode.OPTIMISTIC_FORCE_INCREMENT. I'd like to use this lockmodes, to do a version check/upgrade on commit. But when an entity is loaded inside a transaction, its LockMode is set to READ, that has a greater level (See LockMode class). And hibernate does not "downgrade" a lock. Hibernate manual tells that only ...

4. concurrency with native sql upgrade? transaction?    forum.hibernate.org

hi i have a beginner question. i have i table holdling jobs to be processed by multiple users. every user get himself a set of jobs (the oldest ones by a timestamp) and, of course, i want that not two get the same jobs... sounds for me like transactions would be necessary but, as i understand, they dont prevent multiple users ...

5. Problem with UPGRADE locking    forum.hibernate.org

Hi there, I'm using Hibernate 2.1.2 with MySQL 4.0.14. I have a failry standard class and do something like this to load an instance: Code: Query query = session.getNamedQuery(queryName); for (int i=0; i < names.length; i++) ...

6. LockMode.UPGRADE    forum.hibernate.org

7. LockMode.UPGRADE within a stateless session bean    forum.hibernate.org

I'm trying to obtain a lock on several rows within a session bean. The goal is a resulting "SELECT... FOR UPDATE". The call to list() never returns. No exceptions, no errors. Seems like it's waiting for another lock to be release, but there are no other processes accessing these rows. In fact, while the code is blocked, I've copied the generated ...

8. Facing issues with lockmode.upgrade    forum.hibernate.org

Read the rules before posting! http://www.hibernate.org/ForumMailingli ... AskForHelp Hibernate version: Hibernate 2 here are the string literals that i am using to generate my query public static String GET_AVAILABLE_CTN_NUMBERS_FROM = "from CTNAvailable cTNAvl "; public static String GET_AVAILABLE_CTN_NUMBERS_STATUS_AVAILABLE = "where cTNAvl.status=:status1 "; public static String GET_AVAILBLE_CTN_NUMBERS_STATUS_PICKED = "or cTNAvl.status=:status2 "; public static String GET_AVAILABLE_CTN_NUMBERS_TIMESTAMP = "and :currentTimeStamp > cTNAvl.timeStamp + interval ...

9. Load with LockMode.UPGRADE doesn't lock with SQLServer    forum.hibernate.org

We have recently migrated a product from hibernate 2.1.x to 3.0.x in the hope we could remove an ugly kludge for locking objects in SQLServer. Hibernate 3.0 added support for the (rowlock, updlock) but this appears to only work when directly calling lock. If you call load with a lock mode the lock hint is not added. Loading with a lock ...





10. Hibernate3.1 Upgrade: Error creating Transaction    forum.hibernate.org

Using Hibernate3.1, Hibernate-tools3.1-beta2, Oracle 10g. I'm getting an error when trying to create a transaction. Basically, I think the problem is in the changes in SessionImpl and JDBCContext java classes between Hibernate 3.0 to 3.1. It used to work in the older version. We are using our own custom TransactionFactory. I've shown some of the differences in the code below. Anybody ...

11. Session.get with LockMode.UPGRADE throws StaleObjectStateExc    forum.hibernate.org

We are using managed versioning for optimistic locking. In one case, we were hoping to apply a pessimistic locking strategy that would block one thread from even reading the object until the other thread finished commiting the changes in its transaction (thereby allowing us to apply both changes to the object without overwriting). I thought we could achieve that with the ...

12. LockMode.UPGRADE is invalid with Query.setMaxResults()    forum.hibernate.org

We seem to have found a problem using Hibernate against an Oracle 9.2.0.1 database when using LockMode.UPGRADE in conjuction with the setMaxResults() method on the Query. Our HQL is as follows: -------------------------------- from com.mincom.ellipse.edoi.ejb.msf220.MSF220Rec MSF220Rec where (MSF220Rec.poType = 'T') we setup the query as follows: ------------------------------------------- String hqlString = "from com.mincom.ellipse.edoi.ejb.msf220.MSF220Rec MSF220Rec where (MSF220Rec.poType = 'T')"; Session session = HibernateUtil.getSession(); org.hibernate.Query ...

13. Sybase not able to get exclusive locks usingLOCKMODE.UPGRADE    forum.hibernate.org

In my application I am connecting to Sybase database from hibernate.I tried setting locks using 1.session.load(class,id,LOCKMODE.UPGRADE) 2.session.lock(obj,LOCKMODE.UPGRADE) I tested the lock using threads ,but its not locking the rows.All the thread are being given shared lock.So wen i update the value differs.I have set the transaction isolation level using but stilll its not locking the row.. Can anyone advice ...

14. LockMode.Upgrade never re-loads from db if in session -JIRA?    forum.hibernate.org

I have a simple dao accessor in a transaction: Code: Task taskOrig = taskDao.getTask(multiId); List results = getSessionFactory().getCurrentSession() .createQuery("from Task t where t.multiId=:multiId") .setParameter("multiId", multiId) // for those databases that support it (mysql does) .setLockMode("t", LockMode.UPGRADE) .list(); if (results.size() == 0) return null; ...

15. getObject with LockMode.UPGRADE getting stale data?    forum.hibernate.org

I am having an issue using LockMode.UPGRADE. My code looks like; MyObject a = getObject(criteria, LockMode.UPGRADE); a.incrementCount(); commitTransaction(); What appears to be happening is that several machines/threads try to access the object at once. Thread1 gets the lock. It increments the count from 1 to 2 and commits. Then the second thread gets the lock, but its copy of the object ...

16. LockMode.UPGRADE help on deleting entities in 2 TX    forum.hibernate.org

Hibernate version: 3.2.1GA Name and version of the database you are using: Postgres 8.1.4 Hi, We're having a problem using LockMode.UPGRADE. The situation is as follows: We persist an Object with an id in a TX Then we start 2 TX's in seperate Threads (to simulate parallel processing), in both TX's we first try to get the Object with LockMode.UPGRADE with ...





17. Problem on using LockMode.upgrade in named query inOracle DB    forum.hibernate.org

Newbie Joined: Wed Jan 03, 2007 4:12 am Posts: 11 Location: Singapore Hi all, I am using the pessimistic lock 'Upgrade' in my named query. However I encounter some sql grammar error while executing in Oracle DB. I have tested with Postgres DB and without error. The named query is listed below Code:

18. pessimistic upgrade lock    forum.hibernate.org

I don't know if someone had the same problems that I do.. Here is situation: 1. Let's say I have entity called Account defined in hbm.xml file with following mapping: 2. Let's say I have multiple java threads which ...

19. Upgrade Locking when using Transactional 2nd Level Cache    forum.hibernate.org

I'm trying to figure out whether, or how, I can get Hibernate to acquire an UPGRADE, or WRITE, lock on an entity cached in a transactional 2nd-level cache such as JBoss TreeCache, when I use Session.get or Session.load. Digging inside the code it seems that, by default, Hibernate effectively ignores all LockMode values when the 2-level cache strategy in affect is ...

20. session.refresh(entity, LockMode.UPGRADE) warning    forum.hibernate.org

Can I just ask what is the best method of doing this? Database transactions just aren't enough [with some databases] when dealing with concurrency especially when a limit needs to be checked (such as 'number of items left'). There needs to be some sort of synchronisation/thread locking. How have people solved this?