Reputation: 2084
I'm trying to get the url that the Connection uses to connect the database as following :
getEntityManager().unwrap(SessionImplementor.class).connection().getMetaData().getURL();
But I get this error :
java.lang.IllegalStateException: No transactional EntityManager available
How can I solve this ?
I don't understand why this question was considered as duplicated to a Hibernate solution, I'm using JPA, so I'm trying to get the url using entityManager
and not sessionFactory
.
Upvotes: 0
Views: 220
Reputation: 2084
The solution was to add the @Transactional
annotation.
Upvotes: 1
Reputation: 86
The SessionImplementor Interface is form Hibernate, so which JPA Implementation are you using then?
Upvotes: 0