Hibernate 和 Oracle 12c:未知的 Oracle 主要版本 [12]:无法确定要使用的方言 [name=Oracle,majorVersion=12]
Hibernate and Oracle 12c: Unknown Oracle major version [12] : Unable to determine Dialect to use [name=Oracle, majorVersion=12]
Oracle 连接错误。
WARN: HHH000384: Unknown Oracle major version [12]
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: IntegratorMasterdataPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.evry.App.main(App.java:16)
Caused by: org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:106)
Persistance.xml
<persistence-unit name="IntegratorMasterdataPU" transaction-type="JTA" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@daq-esb-ora01.man.bosng.dk:1521/int_qa" />
<property name="hibernate.connection.driver_class" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.username" value="ERDATA" />
<property name="hibernate.connection.password" value="6g6gqn5" />
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
代码:
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("IntegratorMasterdataPU");
em = emf.createEntityManager();
}
Maven 依赖项:
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.8.Final</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
我需要坚持更换供应商吗?如果是那么什么?或者这是 hibernate.connection.driver_class 中的一个问题?
命中和试炼并使用 Persistance.xml 中的以下属性修复:
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
Oracle 连接错误。
WARN: HHH000384: Unknown Oracle major version [12]
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: IntegratorMasterdataPU] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:78)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.evry.App.main(App.java:16)
Caused by: org.hibernate.HibernateException: Unable to determine Dialect to use [name=Oracle, majorVersion=12]; user must register resolver or explicitly set 'hibernate.dialect'
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:106)
Persistance.xml
<persistence-unit name="IntegratorMasterdataPU" transaction-type="JTA" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@daq-esb-ora01.man.bosng.dk:1521/int_qa" />
<property name="hibernate.connection.driver_class" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.username" value="ERDATA" />
<property name="hibernate.connection.password" value="6g6gqn5" />
<property name="hibernate.archive.autodetection" value="class" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hbm2ddl.auto" value="create" />
</properties>
</persistence-unit>
代码:
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("IntegratorMasterdataPU");
em = emf.createEntityManager();
}
Maven 依赖项:
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.8.Final</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
我需要坚持更换供应商吗?如果是那么什么?或者这是 hibernate.connection.driver_class 中的一个问题?
命中和试炼并使用 Persistance.xml 中的以下属性修复:
<property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />