public interface JpaConnectionExtractor
Extracts the underlying Connection from an EntityManager. There is no standard way defined in JPA to extract the underlying Connection in JPA, but it's possible with vendor-specific code. See examples below
EclipseLink and JPA 2.0
entityManager.unwrap(java.sql.Connection.class);
Hibernate 4.x and JPA 2.0
Session session = entityManager.unwrap(Session.class); SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory(); return sfi.getConnectionProvider().getConnection();
Hibernate 3.x and JPA 2.0
return entityManager.unwrap(Session.class).connection();
Hibernate 3.x and JPA 1.0
Session session = (Session) entityManager.getDelegate(); return session.connection();
| Modifier and Type | Method and Description |
|---|---|
Connection |
extract(javax.persistence.EntityManager entityManager) |
Connection extract(javax.persistence.EntityManager entityManager)
Copyright © 2016. All rights reserved.