Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Unable to unwrap connection with eclipselink.jdbc.exclusive-connection.mode=Always
Unable to unwrap connection with eclipselink.jdbc.exclusive-connection.mode=Always [message #1715137] Thu, 19 November 2015 14:18 Go to next message
Havard Kristiansen is currently offline Havard KristiansenFriend
Messages: 3
Registered: November 2015
Junior Member
When switching to exclusive connections, the application is unable to unwrap java.sql.Connection.

The application works when exclusive-connection-mode is not set.

persistence.xml
<property name="eclipselink.jdbc.exclusive-connection.mode" value="Always"/>
<property name="eclipselink.jdbc.exclusive-connection.is-lazy" value="false"/>

Removing the two lines above will make the application work again.

Code:
...
@Resource
private UserTransaction tx;

@Inject
private EntityManager em // via EntityManagerProducer
...
tx.begin();
em.joinTransaction();
Connection conn = entityManager.unwrap(Connection.class); // Connection is null
...


If I delve into ClientSession I can see that isExclusiveIsolatedClientSesson() is true, but UnitOfWork.getAccessor() returns an Accessor without a Connection.

I thought this would work the same as without exclusive connections, but guess I was wrong.

Any thoughts on how to aquire a connection when using exclusive connections?

Regards,
HÃ¥vard
Re: Unable to unwrap connection with eclipselink.jdbc.exclusive-connection.mode=Always [message #1715887 is a reply to message #1715137] Fri, 27 November 2015 10:36 Go to previous messageGo to next message
Tomas Kraus is currently offline Tomas KrausFriend
Messages: 9
Registered: November 2014
Junior Member
I don't se the way how you opened the transaction. Guess that it shall be dne the same way as in http://wiki.eclipse.org/EclipseLink/Examples/JPA/EMAPI#Getting_a_JDBC_Connection_from_an_EntityManager

UnitOfWork behind your EM is connected with transaction but because there is just em.joinTransaction(), not em.getTransaction().begin(), it may be another UnitOfWork that holds the connection.

Try to do it in exactly the same way as on sample page - start transaction from the same EM which is used for connection unwrap later. If this way does not work, please, file a bug for EclipseLink on https://bugs.eclipse.org/bugs/enter_bug.cgi?product=EclipseLink (for JPA component).
Re: Unable to unwrap connection with eclipselink.jdbc.exclusive-connection.mode=Always [message #1716100 is a reply to message #1715887] Tue, 01 December 2015 09:57 Go to previous message
Havard Kristiansen is currently offline Havard KristiansenFriend
Messages: 3
Registered: November 2015
Junior Member
Thanks for the reply!

I excplicitly create a UserTransaction, and ask the EntityManager to join it, as stated in the example in my previous post.

We use JTA in WebLogic, and EntityTransaction is not allowed in JTA (cannot use entityManager.getTransaction().begin()).

There might be more than one thing I do not grasp here.
Previous Topic:Specifying bound parms in mixed jpa/native query
Next Topic:Moving Eclipselink Entities to separate jar
Goto Forum:
  


Current Time: Tue Mar 09 08:44:59 GMT 2021

Powered by FUDForum. Page generated in 0.01712 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top