After the execution of the main method, the program does not end.

Googled a lot, but everyone writes only about sessionFactory.close();

First, I do not create a session manually in principle. To communicate with the DB, I do get an EntityManager :

 EntityManager manager = Persistence .createEntityManagerFactory("COLIBRI") .createEntityManager(); 

And then I use it, like this:

 public Costumer get(long id) { return manager.find(Costumer.class, id); } 

Call manager.close(); Does not help.

Call ((Session)costumerService.manager.getDelegate()).getSessionFactory().close(); also does not help, although it appears in the logs:

 апр 04, 2017 6:27:42 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop INFO: HHH10001008: Cleaning up connection pool [jdbc:hsqldb:file:testdb] 
  • and this createEntityManagerFactory("COLIBRI") as it is called, if not create a session manually? - Sergey
  • @Sergey Sorry, not correctly expressed. I do not create a session explicitly. It is clear that it is created. - Leon Nash

0