I am trying to persist container managed transaction before its scope comes to end using entityManager.flush()
The bean class is annotated
@TransactionAttribute(TransactionAttributeType.REQUIRED)
Through this link: how we can get JPA EntityManager Flush work, I got to know that using entityManager.flush() will not commit the transaction. DBMS will now be aware of this data, but other DB sessions will not be able to see it.
Also I tried to create a new bean method annotated
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
following this link how to commit a transaction in EJB? to call entityManager.flush() in other transaction whose scope is within the new bean method. However this doesn't work.
I am looking for an approach to forcefully commit a transaction to persist its so far current state in DB.
Something like:
entityManager.getTransaction().commit();
this can be done for BMT but not CMT.