老师,configure()后面要加个文件路径,不然只会去默认的地方找,如果找不到就报错,同学们要注意
2016-02-09
添加了<property name="hibernate.current_session_context_class">thread</property>
getCurrentSession()还是报错
getCurrentSession()还是报错
2016-02-01
session=sessionFactory.openSession();//打开会话
transaction=session.beginTransaction();//打开事务
transaction.commit();//提交事务
session.close();//关闭会话
sessionFactory.close();//关闭会话工厂
transaction=session.beginTransaction();//打开事务
transaction.commit();//提交事务
session.close();//关闭会话
sessionFactory.close();//关闭会话工厂
2016-01-13
//创建初始化
@Before
Configuration config=new Configuration().configure();//创建配置对象
//创建服务注册对象
ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties).buildServiceRegistry();
sessionFactory=config.buildSessionFactory(serviceRegistry);//创建会话工厂
@Before
Configuration config=new Configuration().configure();//创建配置对象
//创建服务注册对象
ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties).buildServiceRegistry();
sessionFactory=config.buildSessionFactory(serviceRegistry);//创建会话工厂
2016-01-13