-->
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: How do I request a lock on a query?
PostPosted: Wed Oct 15, 2008 7:52 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
I am trying to automatically assign account numbers in an accounting system by finding the highest account number in a given range and then adding one to it.

Basically, select max(number) from account where number >= :min and number <= :max and business = :business.

However, what I've noticed is that two accounts added simultaneously may get the same number. Obviously I'm not getting a write lock on the query for the last account number in use.

I'm using PostgreSQL 8 and glassfish via the JPA EntityManager API.

What I don't know is - is there any way to request a lock on this query so that the second add has to wait for the first one to complete before it can try to calculate the last used account number?


Thanks!


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.