The method buildSessionFactory() from the type Configuration is deprecated.SessionFactory的变化

  

  在创建Configuration对象之后:Configuration cfg = new Configuration().configure();
  要通过Configuration创建SessionFactory对象:

  1. SessionFactory sf = cfg.buildSessionFactory();  // 是Hibernate3.X时的写法

  2. ServiceRegistry sr = new ServiceRegistryBuilder().applySettings(cfg.getProperties()).buildServiceRegistry();是Hibernate4.3 ~ Hibernate4.0时的

  3. ServiceRegistry sr = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build();  

   SessionFactory sf = cfg.buildSessionFactory(sr);  // Hibernate4.3时的

猜你喜欢

转载自www.cnblogs.com/yueyou/p/9501969.html
今日推荐