Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > entity EJB concurrent access

Thread Tools

entity EJB concurrent access
Posts: n/a
This is my piece of code that doesn't work and I have no idea why:

//this is a method in a message driven bean
MyEntity myEntity = manager.find(MyEntity.class, objektId);

if (myEntity.getStatus()==Consts.OPEN)

I have a second message driven bean with similar method invoked on the
same entity. When they are invoked at the same time I get these errors:

Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.4 (Build
060412)): oracle.toplink.essentials.exceptions.DatabaseExcep tion
Internal Exception: org.postgresql.util.PSQLException: ERROR: could not
serialize access due to concurrent updateError Code: 0
Call:UPDATE MyEntity SET status = ?, version = ? WHERE ((id = ?) AND
(version = ?))
bind => [3, 118, 258, 117]

I don't understand why manager.lock doesn't prevent that. I have no
other methods accessing this table.
Secondly, why don't I get OptimisticErrorException?
Thirdly, what is a "good" semantics of dealing with concurrent access
(I can't avoid concurrent access, and because these methods are invoked
from a message bean it is essential that they complete successfuly.
Otherwise noone would know that something went wrong - except for logs
How can I retry my method?)

My software is
- Sun Java Application Server 9.0
- PostgreSQL 8.1
- Windows XP

Thanks in advance

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Possible to generate "ejb-jar.xml" from EJB class (source)? "ejb-jar.xml" appserver independent? Raymond Schanks Java 0 08-03-2010 08:21 AM
How to relate a SQL based entity with an Object based entity in Entity Framework markla ASP .Net 1 10-06-2008 09:42 AM
Entity Name or Entity Number? Samuel van Laere HTML 4 02-24-2007 10:11 PM
problems locating the concurrent EDU.oswego.cs.dl.util.concurrent package Pep Java 6 08-16-2005 07:26 AM
Dynamically Access & Call An EJB From Another EJB? Steve Java 1 07-15-2003 06:47 PM