Hello Sesques.
I appreciate your help.
Here is a snippet of code. As you can see, the addAttendance of this STATELESS bean
is calling the findAttendance method with an specific memberId and timeSlotId. In the
logs, I can see that two threads are calling this method almost at the same time but
the first thread get to the deleteAttendance method and remove the record from the db.
Meanwhile, the second thread went into a waiting state because the first one is
working within a transaction. But when it wakes up, it tries to execute code based on
the primary keys that got from the findByMemberAndTimeSlotId method that is part of
the findAttendance method.
I am still confused why the container lets 2 threads execute the
findByMemberAndTimeSlotId concurrently the first time.
By the way, the entity bean has transaction type "Required" and the finder methods are
NOT read-only. The only methods that are read-only are the get methods. And the
commit-option is A
/**
| * @ejb.interface-method
| *
| * @ejb.transaction
| * type="Required"
| */
| public void addAttendance(String inConferenceId, String inMemberId, String
inGroupId, String inTimeSlotId)
| {
| ...code...
|
| // get the record for the current time slot
| attendanceMain = findAttendance(inMemberId, inTimeSlotId);
|
| ...more code...
|
| // delete the existing attendance record
| deleteAttendance(attendanceMain);
|
| ...more code...
| }
|
|
| /**
| * @ejb.interface-method
| *
| * @ejb.transaction
| * type="Required"
| */
|
| public AttendanceVO findAttendance(String inMemberId, String inTimeSlotId)
| {
| AttendanceVO retval = null;
| logger.debug("findAttendance invoked");
| try
| {
| AttendanceLocalHome alh = AttendanceUtil.getLocalHome();
| AttendanceLocal al = alh.findByMemberAndTimeSlotId(inMemberId,
inTimeSlotId); //second thread gets into a wait state while the first one is doing
transactional process.
| retval = al.getAttendanceVO(); //pk for attendance is gone at this point,
exception get thrown here
| }
| catch (FinderException fe)
| {
| logger.debug(fe.getMessage());
| }
| catch (NamingException ne)
| {
| logger.warn(ne.getMessage(),ne);
| }
| return retval;
| }
|
|
| /**
| * @ejb.interface-method
| *
| * @ejb.transaction
| * type="Required"
| */
| public boolean deleteAttendance(AttendanceVO inAttendance)
| {
| boolean retval = false;
| if (inAttendance != null)
| {
| try
| {
| AttendanceLocalHome alh = AttendanceUtil.getLocalHome();
| AttendanceLocal al = alh.findByPrimaryKey(inAttendance.getId());
| if (al != null)
| {
| try
| {
| al.remove();
| retval = true;
| }
| catch (RemoveException re)
| {
| logger.warn(re.getMessage());
| }
| }
| }
| catch (FinderException fe)
| {
| logger.warn(fe.getMessage());
| }
| catch (NamingException ne)
| {
| logger.warn(ne.getMessage(),ne);
| }
| }
| return retval;
| }
|
Thanks for the help
jchang
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3830484#3830484
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3830484
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user