用5.xx的小伙伴们,可以用这个代码。
Configuration cfg=new Configuration();
cfg.configure();
SessionFactory sessionFactory =cfg.buildSessionFactory();
Session session=sessionFactory.openSession();
Transaction tx=session.beginTransaction();
Configuration cfg=new Configuration();
cfg.configure();
SessionFactory sessionFactory =cfg.buildSessionFactory();
Session session=sessionFactory.openSession();
Transaction tx=session.beginTransaction();
2017-11-06
使用Hibernate5.0以后的注意了,创建服务对象和会话工厂对象的方法有变.具体方法 :
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
sessionFactory = new MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory();
参考文章:http://blog.csdn.net/bingjianit/article/details/68954250
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
sessionFactory = new MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory();
参考文章:http://blog.csdn.net/bingjianit/article/details/68954250
2017-11-01