Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help needed - Persist 2 entities

User_9NVHRJun 6 2017

Hi All,

Am new to EJB and trying the below scenario.

Below is my use case and am facing difficulty in accomplishing this.

i need to persist some data for an entity and using the data from this entity i need to persist data into a history table (insert a new row for each column present in my first entity).

Am trying to persist 2 entities in a single transaction, below is the flow that am using.

in bean1:

@EJB

bean2 da;

method1(object)

{

em.persist(object);

da.callhistorymethod(object)

return object

}

in bean2:

callhistorymethod(historyobject)

{

---do somthing---

em.persist(historyobject);

}

while running the process, it gives me the below error:

java.lang.IllegalStateException: The transaction associated with this transaction-scoped persistence context has been rolled back and as a result,

the EntityManager has been closed. No further operations are allowed in this transaction context. Please see the server log for the cause of the rollback.

request you to help me with the above issue.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 4 2017
Added on Jun 6 2017
0 comments
674 views