tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From QM <qm...@brandxdev.net>
Subject Re: method level synchronization doesn't work
Date Thu, 30 Sep 2004 21:43:33 GMT
On Thu, Sep 30, 2004 at 05:31:25PM -0400, Malia Noori wrote:
: Thank you for replying, but I would appreciate it if you could expand on
: your explanation.  Here is my original post:
: 
: Actually, the data that I am modifying requires a transaction and
: > synchronization.  It increments a counter stored in the database.  So, I
: > have to do a select to get the current value, increment the counter, and
: > then insert the new value.

This needn't be done within code; you could perform a database-level
transaction.  For example, using raw SQL calls that would come down to:

	. set the Connection's autoCommit to false
	. do the DB work
	. call the Connection's commit() method


I recall EJBs have their own transaction mechanism, and I'd be
shocked[1] if something as popular as Hibernate didn't have one as well.
Check the respective docs.

Whatever the case, there should be no need to try to synchronize this at
the app/code level.

-QM

[1] = I've been shocked before, though... ;)


-- 

software  -- http://www.brandxdev.net
tech news -- http://www.RoarNetworX.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message