JBoss 4.2.2
MySQL 5.0
Is it possible to use an entity bean as a parameter to a stateless session bean method? I would guess so, but...
I have one SLSB something like this:
Code:
@PersistenceContext(unitName="myunit") EntityManager em;
@EJB OtherSLSB slsb2;
...
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void methodX(Integer id) {
FooEntity foo = findFooEntity(id);
...
slsb2.methodY(foo);
}
and another SLSB:
Code:
@PersistenceContext(unitName="myunit") EntityManager em;
...
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void methodY(FooEntity foo) {
// Try to do something with foo here
}
Whatever I try, I can't do anything much with
foo in methodY. I either get LazyInitializationExceptions, or if I merge the
foo entity, I get other exceptions related to stale states etc. Isn't this supposed to work? Shouldn't the transaction in the first SLSB propagate to the second one, not causing any lazy exceptions?! Am I missing something obvious?