Session Bean Transaction Problem

I have a session bean S with a method foo1(). S.foo1() calls an entity bean A (which has multiple child entity beans of type B) twice via its method bar() which creates a new child entity B. In other words, you call the session bean which calls the entity bean twice and tells it each time to add a new child entity bean. These two calls to create the child entity beans must be made sequentially, with no calls intervening (in the database, the first child must be directly before the second child). However, it is possible for multiple clients to call S.foo1(), and the only thing we can rely on for transactional isolation (according to the spec) is the underlying database. But since nothing in entity bean A is being changed in the database (only rows for B are being inserted), there doesn't seem to be a way to get the transactional isolation we need. Anyone have any thoughts, solutions? Or am I missing something. It seems that, even if the code in the session bean were pushed down into the entity bean, we'd still have the same problem, since we can only rely on the database for transactional isolation.

Using EJB1.1 (JBoss) and JDK1.3.1

-Daniel

[1186 byte] By [danielboggs] at [2007-9-26 2:02:23]
# 1

As a clarification (in case my previous description was too obscure), say for instance you had an entity bean called Parent with a Parent table in the database, and an entity bean called Child with a Child table in the database, in a master-detail relationship.

You can tell a parent (Bob) to add (adopt?) more children and it will create new children related to the parent. Whenever anyone tells Bob to add more children, he has to add a boy child followed by a girl child. If two people tell Bob to create more children at about the same time, there seems to be a possibility of some interleaving, for instance, creating boyA, boyB, girlA, girlB, instead of boyA, girlA, boyB, girlB.

Since it seems to me that the EJB1.1 spec only _guarantees_ transactional isolation at the database level (as much as the database gives you), and since we are just doing inserts here (of child records), is there any way to ensure that when we add a set of children, it's always boyX followed by girlX? Or am I missing a key point here.

It seems (?) that the JBoss server we are using actually locks the entity bean (Bob) itself, which would give us the synchronization we need, but I don't think that has to be the case with an EJB app server (i.e., it could just rely on the database; see section 9.1.11 of the EJB1.1 spec).

Any thoughts would be appreciated. Thanks.

-Daniel

danielboggs at 2007-6-29 8:43:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...