Hibernate is able to disconnect and reconnect a Session from its underlying JDBC connection using Session.disconnect and Session.reconnect(Connection).
Is there a way to achieve the same using only JPA? If not, is there an alternative pattern in JPA that allows me to keep a long running JPA session open while temporarily releasing the underlying JDBC connection.
Regards,
Jochen
There is no such method in neither EntityManagerFactory nor EntityManager.
You can create a long running EntityManager with @PersistenceContext(type=PersistenceContextType.EXTENDED) or EntityManagerFactory.createEntityManager(), but there are no methods for disconnect and reconnect of a Connection.
However, if after closing a EntityManger, you may create a new EntityManger and reconnect any detached entities with EntityManger.merge() (and then EntityManger.refresh() if desired).