hibernate4.3.4.final出现的一个有关问题

hibernate4.3.4.final出现的一个问题
Exception in thread "main" org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
程序基本没动过,以前用的3.3.2的版本,今天换成4.3.4的版本后,改了一下sessionFactory的生成方法,其他的不变,开始还能运行,过了30min左右,就不能运行了!
------解决思路----------------------
出现错误的根本原因不在于配置文件,而是在于hibernate的SessionFactory的生成策略

在hibernate4中已经把原有的SessionFactory sessions = cfg.buildSessionFactory();
这种方法标记为过时的了。

在hibernate4中,构建SessionFactory 需要加入参数ServiceRegistry
这里给了一种可行的方式:

Configuration cfg = new Configuration().configure();
StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(cfg.getProperties()).build();
SessionFactory sessionFactory = cfg.buildSessionFactory(serviceRegistry);