2
In an environment Javaee, there is the possibility to extract the JDBC connection(java.sql.Connection
) using JTA
?
I have a datasource in Wildfly, where I inject in the following way:
@PersistenceContext
private EntityManager entityManager;
Have any way to extract the JDBC connection from this Entitymanager?
I found a way (but it didn’t work):
Connection connection = entityManager.unwrap(java.sql.Connection.class);
The following error has been released:
javax.persistence.Persistenceexception: Hibernate cannot unwrap java.sql.Connection interface
SessionFactoryImplementor
does not have the methodgetConnectionProvider
– Henrique Santiago
What is the version of your JPA implementation ?
– LR10
Java ee 7, i.e., JPA 2.0
– Henrique Santiago