hibernateoracle12chibernate-mappingdialect

Hibernate and Oracle 12c: Unknown Oracle major version [12] : Unable to determine Dialect to use [name=Oracle, majorVersion=12]


Oracle Connection error.

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>

Code:

public static void main(String[] args) {

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("IntegratorMasterdataPU");
    em = emf.createEntityManager();

}

Maven Dependencies:

<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>

Do i need to change provider in persistance? If yes then what? or is this an issue in hibernate.connection.driver_class?


Solution

  • Hit and Trials and fixed using below properties in Persistance.xml:

            <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />