Search code examples
javajpapersistenceeclipselinkconnection-pooling

Is the connection Pool configuration kept outside JPA Context?


Hello i am extracting the connection object from the EclipseLink context by calling: Connection con = entityManager.unwrap(Connection.class);

i am responsible for releasing the Connection in order it to comeback into the pool however i need to know if the extracted connection is supposed to keep the original configuration set by EclipseLink i mean number of connections, Maximum number of connections and so on..if so then once it is returned into EclipseLink it is supposed to keep the same performance than working normally..

i need to know this cause maybe the experience of someone can help me in choosing if getting the connection in this way will keep a good performance as EclipseLink does when working its native JPA, thanks in advance..


Solution

  • You can only unwrap the Connection in the scope of a transaction. So you will get the same connection that the EntityManager is bound to (from the pool). You must not release this connection, EclipseLink will release when the transaction ends.

    So, to be clear, you are NOT responsible for releasing the connection.