spring-data-jdbc support for Oracle

Viewed 1752

I like the approach of spring-data-jdbc very much, but it seems it does not have support for Oracle. https://docs.spring.io/spring-data/jdbc/docs/2.0.1.RELEASE/reference/html/#requirements Is it possible to manage with Mybatis all what can be done with spring-data-jdbc by using Mybatis support in spring-data-jdbc. Essentially, I like to keep the design approach and domain driven approach of spring-data-jdbc and use Mybatis in spring-data-jdbc. This way, I can start leveraging spring-data-jdbc apis and approach till Orcale is supported. Or it will be better for me to stick with plain Mybatis and not use Mybatis and spring-data-jdbc at this point.

3 Answers

If you are interested in using Spring Data JDBC with Oracle I'd just go ahead and do it by implementing a Dialect. People have used it with Oracle before a Dialect was required.

You will probably encounter features that don't work yet, but should be able to work around them with annotated queries, some RowMappers and occasionally a custom method implementation.

Can you not use 2.2.6.RELEASE or 2.3.0.RELEASE of Spring Data? It does support Oracle. The following dependencies works well.

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.3.0.RELEASE</version>
</parent>


<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>


<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>

    <dependency>
        <groupId>com.oracle.database.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <version>19.6.0.0</version>
    </dependency>

</dependencies> 

I just set a simple example with the Oracle DB and Spring Data JDBC and Spring Data JPA and it worked ok (no need for Dialect either). Could you give more information about your case? Or you assume is not supported because is not listed in the link you shared?

Related