I am using the Hibernate Session obtained from em.unwrap(..)
method. I couldn't seem to find any info on whether I have to release it after usage. The transaction is managed by the bean and the entity manager is injected using @Inject
.
boolean transactionSuccess = false;
try {
utx.begin();
final Session session = em.unwrap(Session.class);
transactionSuccess = true;
} finally {
commitOrRollback(transactionSuccess);
}
I presume that the entity manager instance is managed by the container. Since the Session is more or less the underlying implementation do I have to release it? It is AutoCloseable
after all.
the only relevant info i found was this (but it seems vanilla JPA): After using the unwrap method on entitymanager to get the native hibernate session do I have to close both?