Mr_Failure
2015-12-07 22:57
一直报空指针异常,不知道怎么解决啊,纠结
想问问这个问题最后解决了吗,我也是一直空指针异常
错误信息贴全吧
public class StudentsTest {
private SessionFactory sessionFactory;
private Session session;
private Transaction transcation;
@Before
public void init(){
//创建配置对象
Configuration config=new Configuration().configure();
//创建服务注册对象
ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
//创建会话工厂对象
sessionFactory=config.buildSessionFactory(serviceRegistry);
//会话对象
session=sessionFactory.openSession();
//开启事务
transcation=session.beginTransaction();
}
@After
public void destory(){
transcation.commit();//提交事务
session.close();
sessionFactory.close();
}
@Test
public void testSaveStudent(){
Students s=new Students(1,"张三丰","男",new Date(),"武当山");
session.save(s);
}
}
没代码,怎么测试?
信息不全
Hibernate初探之单表映射
74808 学习 · 793 问题
相似问题