Search code examples
jpaeclipselink

How to set "unchained transaction mode" from entity manager


I am trying to call a stored procedure using native query call from an entity manager like this

String command = "..."//my stored procedure call command
Query q =  getEntityManager().createNativeQuery(command);

But when i run it I got the following message:

Exception, procedure ... can be run only in unchained transaction mode...

I know if I have a connection object, i can set con.setAutoComit(true) to make this work. But my question is: since I have a entity manager object, can i set this somehow from entity manager object? I'd like to have the container to manage all the database resources...

I am using EclipseLink.

thanks.

One more note: i don't have the control over the database side,so i cannot go and change the transaction mode to "any".


Solution

  • I found the solution:

    getEntityManager().createNativeQuery("set chained off").executeUpdate();