You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by "Makkus B. (Jira)" <ji...@apache.org> on 2021/11/23 08:58:00 UTC
[jira] [Created] (TOMEE-3816) Return "this" on stateless EJB method looses container transaction management
Makkus B. created TOMEE-3816:
--------------------------------
Summary: Return "this" on stateless EJB method looses container transaction management
Key: TOMEE-3816
URL: https://issues.apache.org/jira/browse/TOMEE-3816
Project: TomEE
Issue Type: Bug
Components: TomEE Build
Affects Versions: 8.0.8
Environment: TomEE 8.0.8, MS Windows 10, OpenJDK 15
Reporter: Makkus B.
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):
{{{}@Stateless{}}}{{{}class 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. )
--
This message was sent by Atlassian Jira
(v8.20.1#820001)