解决HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=19]的问题

问题描述

       客户基础环境升级,操作系统RedHat从 6.4升级到7.4 ,JDK从1.7升级到1.8,weblogic从11g升级到12g,Oracle从11g升级到12c。

       启动报错:

……
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.git.framework.core.dao.impl.BaseDao.setHibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in URL [zip:/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/ecms_domain/servers/AdminServer/tmp/_WL_user/EasyCMS/rr10vo/war/WEB-INF/lib/_wl_cls_gen.jar!/spring/app-resources.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [zip:/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/ecms_domain/servers/AdminServer/tmp/_WL_user/EasyCMS/rr10vo/war/WEB-INF/lib/_wl_cls_gen.jar!/spring/app-resources.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=19]; user must register resolver or explicitly set 'hibernate.dialect'
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in URL [zip:/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/ecms_domain/servers/AdminServer/tmp/_WL_user/EasyCMS/rr10vo/war/WEB-INF/lib/_wl_cls_gen.jar!/spring/app-resources.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [zip:/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/ecms_domain/servers/AdminServer/tmp/_WL_user/EasyCMS/rr10vo/war/WEB-INF/lib/_wl_cls_gen.jar!/spring/app-resources.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=19]; user must register resolver or explicitly set 'hibernate.dialect'
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
	Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [zip:/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/ecms_domain/servers/AdminServer/tmp/_WL_user/EasyCMS/rr10vo/war/WEB-INF/lib/_wl_cls_gen.jar!/spring/app-resources.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=19]; user must register resolver or explicitly set 'hibernate.dialect'
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
	Truncated. see log file for complete stacktrace
Caused By: org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=19]; user must register resolver or explicitly set 'hibernate.dialect'
	at org.hibernate.dialect.resolver.DialectFactory.determineDialect(DialectFactory.java:130)
	at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:96)
	at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:117)
	at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
	at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
	Truncated. see log file for complete stacktrace

 

分析

原因是Hibernate 3.*.*不支持Oracle 12。StandardDialectResolver无法解析Oracle12的方言。

 

解决

方案一:升级hibernate4。

方案二:强制使用Oracle10方言。

org.hibernate.dialect.OracleDialect

修改成==》

org.hibernate.dialect.Oracle10gDialect

 

你可能感兴趣的:(Hibernate)