99我啊。。hibernate config在多线程下的问题!
-----------------------------------------------
我用hibernate连接数据库,数据访问对象为:
复制内容到剪贴板
代码:
public class DAORootAB {
private Session session;
/**
* DAO构造器
*/
public DAORootAB() {
createSession();
}
public void createSession() {
// TODO 创建会话
System.out.println("---");
if (this.session == null) {
Configuration config = new AnnotationConfiguration().configure();
SessionFactory factory = config.buildSessionFactory();
this.session = factory.openSession();
}
}
... 其他略
当我使用线程访问是,却无法加载这个类,跟踪程序到Configuration config = new AnnotationConfiguration().configure(); 这一行就在中断。
简单的线程如下:
代码:
public class WorkThread implements Runnable{
@Override
public void run(){
DAORootAB dao = new DAORootAB();
}
}
测试代码(Junit4.4)
代码:
public class MailRunnerTC {
@Test
public void testname() throws Exception {
new Thread(new WorkThread()).start();
}
hibernate配置文件略了。。。
各位帮帮忙