【发布时间】:2014-04-13 17:24:31
【问题描述】:
我必须从Hibernate 4.2.3 升级到Hibernate 4.3.4 来测试一些JPA 2.1 规范。我只更改了code这一行
上一行:
final org.hibernate.service.ServiceRegistry serviceRegistry = new org.hibernate.service.ServiceRegistryBuilder().applySettings(hibConfiguration.getProperties()).buildServiceRegistry();
新添加的代码行
final org.hibernate.service.ServiceRegistry serviceRegistry = new org.hibernate.boot.registry.StandardServiceRegistryBuilder().applySettings(hibConfiguration.getProperties()).build();
问题我有一个主要方法只是为了测试一些Criteria API 但main method 永远不会用最新的Hibernate Version 完成我已经检索了正在运行的线程,并且使用最新版本的线程如下。
ThreadList:
[threadID:]2 [threadName:] Reference Handler [isDaemon:] true [isAlive:] true
[threadID:]3 [threadName:] Finalizer [isDaemon:] true [isAlive:] true
[threadID:]4 [threadName:] Signal Dispatcher [isDaemon:] true [isAlive:] true
[threadID:]5 [threadName:] Attach Listener [isDaemon:] true [isAlive:] true
[threadID:]10 [threadName:] Abandoned connection cleanup thread [isDaemon:] true [isAlive:] true
[threadID:]11 [threadName:] pool-1-thread-1 [isDaemon:] false [isAlive:] true
[threadID:]1 [threadName:] main [isDaemon:] false [isAlive:] true
与以前的版本相比,这个线程是新的。
[threadID:]11 [threadName:] pool-1-thread-1 [isDaemon:] false [isAlive:] true
根据规范不是守护进程。
No, it is not. The virtual machine terminates if the last non-daemon thread has finished. It doesn't have to be the main thread.
我认为这个话题至少在 5 分钟内不会结束。
问题只出现在创建 HibernateSessionFactory。
public static void main(String[] args)
{
HibernateHandler handler = new HibernateHandler(true);//creates the HibernateSessionFactory
return;//JVM not finish at this point
}
我希望我的 JVM 以 main 方法结束..
我做错了什么..
【问题讨论】:
标签: java multithreading hibernate jpa