Hi,
I am trying to persist a data by using EntityManager.persist method. I am using
EJB 3.0 Stateless Session Facade Bean and its transaction is Container-Managed. (CMP)
After persist operation, within the same ejb method, I am trying to update the data by using a
JDBC "Update" query. But the problem is that the data is not updated. The transaction is not committed before the execution of the ejb method finishes, I know that. But even if that's the case, the data should be updated, as I know.
The code is given below:
So when I check the data from the database, the created_by column remains as "H", it is not updated. But when I try to update the data by using the pojo and EntityManager.merge method with the given code below:
The data is updated in the database in the same transaction of persisting.
But I need to use the JDBC query within the ejbMethod.
I have tried "conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);" , but it did not work.
I think the transaction that the jdbc connection uses is different than the transaction that the persist operation uses.
How will I resolve this problem? Is there any setting that I need to configure?
Thanks in advance.