Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Invalid
-
8.0.8
-
None
-
TomEE 8.0.8, MS Windows 10, OpenJDK 15
Description
I experienced the following confusing behaviour in Tomee/OpenEjb when trying to construct a builder pattern with a @stateless session bean. When I return "this" from a builder pattern method, container managed transaction seemst to get lost. E.g a call to an EntityManagers persist() method, will throw a TransactionRequiredException.
For reproduction figure this ejb (pseudocode):
@Statelessclass MyEjb {{}@PersistenceContext
EntityManager em;
public MyEjb getMe(){
doSomeInternals();
return this;
}
public void createSomething(){
em.persist(new SomeEntity());
}
in some client, if I call:
myEjb.createSomething()
the entity is created and stored. However, when I call
myEjb.getMe().createSomething();
the TransactionRequiredException is thrown.
Question:
Is this an intended behavior? (I couln'd find any documentation in EJB why this would not be allowed to do. )