Configuration cfg = new Configuration().configure();
SessionFactory factory = cfg.buildSessionFactory();
Session session = null;
session = factory.openSession();
上面代码中,factory不为空,但是session却为空?求解!谢谢!
http://www.iteye.com/problems/7773
这个问题说明你前面的SessionFactory的获取就出了问题。建议你使用try..catch包围这两句话,看下获取SessionFactory对象过程中有没有出现异常。
此外检查下数据库连接的配置文件。