-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate with Spring and JTA cannot lock records
PostPosted: Fri Jan 05, 2007 1:49 pm 
Newbie

Joined: Tue Sep 21, 2004 12:39 pm
Posts: 18
Hibernate version:
3.1.3

Name and version of the database you are using:
PostgreSQL 8.1 / EnterpriseDB 8.1

The generated SQL (show_sql=true):
select channel0_.id as id35_0_, channel0_.version as version35_0_, channel0_.company_id as company3_35_0_, channel0_.admin_name as admin4_35_0_, channel0_.group as group35_0_, channel0_.description as descript6_35_0_, channel0_.data_type as data7_35_0_, channel0_.transport_id as transport8_35_0_, channel0_.creation_date as creation9_35_0_, channel0_.modified_date as modified10_35_0_, channel0_.status as status35_0_, channel0_.max_throughput as max12_35_0_, channel0_.max_attempts as max13_35_0_, channel0_.schedule as schedule35_0_, channel0_.config as config35_0_, channel0_.start_date as start16_35_0_, channel0_.end_date as end17_35_0_ from sync_channel channel0_ where channel0_.id=?

Other versions:
Tomcat 5.5
JDK 1.5
JOTM
Spring 1.2.8

Currently I have a object that needs to be locked, it is used to generate a unique ID. If multiple threads attempt to get the 'next id' the ID generator needs to lock the row (LockMode.UPGRADE) get the next ID, increment and update the record.

This works fine when I use standard JDBC transactions, the row is locked and other requests are blocked until the transaction is commited. However once I switched to JTA everything appears to work correctly, objects are updated, queried etc. but when a 'select for update' is performed the lock does not permit other threads from obtaining a reference to the row.

The only thing I can think of is that I'm not using an XA datasource, or maybe the driver is not an XA driver. However I'm connecting only to one database, the reason for using JTA is that I'm using the JBoss Cluster Cache and it requires it.

Any help, or insight would be greatly appreciated. Looking at the hibernate and spring logs, it appears that no new transactions are being created and that Spring is resuing the the same UserTransaction.

Thanks.

_________________
David Launen


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

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.