I created a program using Hibernate.
The program reaches the main function end, nevertheless the program is running.
I wonder if it happens when Sessio
I am using hibenate 5.2.12 with sqlite 3.20.1, managing the connection manually. In my case the problem was that not only the entity manager had to be closed but also the entity manager factory.
With these attributes:
EntityManager entityManager;
EntityTransaction entityTransaction;
This snippet is used when opening the DB and starting a transaction:
EntityManagerFactory emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME, map);
entityManager = emf.createEntityManager(map);
entityTransaction = entityManager.getTransaction();
entityTransaction.begin();
This snipped is used to commit the transaction and close the DB:
entityTransaction.commit();
if ( entityManager.isOpen() ) {
entityManager.close();
}
EntityManagerFactory emf = entityManager.getEntityManagerFactory();
if ( emf.isOpen() ) {
emf.close();
}
Now with emf.close(); my application terminates as is should be.