program using hibernate does not terminate

前端 未结 13 888
孤街浪徒
孤街浪徒 2020-12-25 10:14

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

13条回答
  •  长情又很酷
    2020-12-25 11:05

    It seems that Hibernate 4.3.1 introduced a bug. I create the connection in my application with:

    EntityManagerFactory connection = Persistence.createEntityManagerFactory(...)
    

    but even if the createEntityManagerFactory method fails with an exception, the service registry remains open. However, as you could see from the above code, I cannot terminate my application because as the method didn't succeed the variable connection wasn't assigned (it is null), so I cannot call connection.close() that would destroy the service registry. It seems that this is really a bug, because how will I be able to release resources without resorting to a hack, like using specific Hibernate APIs from a JPA application?

提交回复
热议问题