We have some problems in mapping an attribute of an entity in the java side with a column in the database side. What is the most efficient way to handle mapping between a native oracle JSON column and a java object? We need to work on the JSON object using the native operations provided by oracle
We are using Spring Boot 2.7.x with Oracle 21c version. Here's our class and pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version.max>18</java.version.max>
<org.springframework.boot.version>2.7.8</org.springframework.boot.version>
<logback.version>0.1.5</logback.version>
<org.projectlombok.version>1.18.22</org.projectlombok.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${org.springframework.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Spring boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- Logback -->
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-json-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback.contrib</groupId>
<artifactId>logback-jackson</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
Product.java
@Entity
@Table(name = "product")
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "externalId")
private String externalId;
// JSON Oracle Type - How to handle it?
@Column(name = "entity")
private byte[] entity;
}
The column is defined as "ENTITY" JSON
Any suggestion?