Hibernate Dialect must be explicitly set解决方法

Exception in thread "main" org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at org.hiber.PsonOperate.<init>(PsonOperate.java:14)
at org.hiber.TestDemo.main(TestDemo.java:12)

正确代码如下:

public PsonOperate(){
    Configuration config=new Configuration();
       SessionFactory factory=config.configure().buildSessionFactory();
       this.session=factory.openSession();
   }

出错代码如下:

public PsonOperate(){
    Configuration config=new Configuration();
       SessionFactory factory=config.buildSessionFactory();//少了configure()
       this.session=factory.openSession();
   }

你可能感兴趣的:(Hibernate Dialect must be explicitly set解决方法)