|
| Re: Getting a JDBC Connection from an EntityManager returns null in EclipseLink 2.0.2 [message #650361 is a reply to message #649824] |
Mon, 24 January 2011 10:57   |
James Sutherland Messages: 1834 Registered: July 2009 |
Senior Member |
|
|
I think the issue is that your are using an external transaction controller, i.e. a JTA DataSource.
I updated the code in the example to handle this,
entityManager.getTransaction().begin();
UnitOfWork unitOfWork = (UnitOfWork)((JpaEntityManager)entityManager.getDelegate()).getActiveSession();
unitOfWork.beginEarlyTransaction();
Accessor accessor = unitOfWork.getAccessor();
accessor.incrementCallCount(unitOfWork.getParent());
accessor.decrementCallCount();
java.sql.Connection connection = accessor.getConnection();
...
entityManager.getTransaction().commit();
You could also acquire the connection directly from the JTA DataSource.
James : Wiki : Book : Blog
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01901 seconds