你的位置:首页 > Java教程

[Java教程]Hibernate4.3.x issue


for running wrong information:Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not

change:

private static SessionFactory buildSessionFactory() {    try {      // Create the SessionFactory from hibernate.cfg.      return new Configuration().configure().buildSessionFactory(        new StandardServiceRegistryBuilder().build() );    }    catch (Throwable ex) {      // Make sure you log the exception, as it might be swallowed      System.err.println("Initial SessionFactory creation failed." + ex);      throw new ExceptionInInitializerError(ex);    }  }


 

to:

private static SessionFactory buildSessionFactory(){    try{      Configuration cfg = new Configuration().configure();      StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()      .applySettings(cfg.getProperties()).build();      return cfg.buildSessionFactory(serviceRegistry);    }catch(Throwable e){      System.err.println("failed to initial SessionFactory"+e);      throw new ExceptionInInitializerError(e);    }  }