How do you retrieve and then release a direct database connection using the eclipse link

As stated in this thread. I have a batch import process that really works very badly with JPA, and I need a way to get back to pure JDBC calls to complete the job.

Apparently you can call:

Connection c = ((EntityManagerImpl)(em.getDelegate())).getServerSession().getAccessor().getConnection();

But I do not know what to do to release and / or close it after completion.

+3
source share
1 answer

See, http://wiki.eclipse.org/EclipseLink/Examples/JPA/EMAPI#Getting_a_JDBC_Connection_from_an_EntityManager

Basically, you should do this in the context of a transaction, a connection will be released when the transaction is completed or the transaction is rolled back.

. ,

http://wiki.eclipse.org/Optimizing_the_EclipseLink_Application_%28ELUG%29

+3

Source: https://habr.com/ru/post/1778643/


All Articles