diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/README.md b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/README.md new file mode 100644 index 00000000..a8b901ca --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/README.md @@ -0,0 +1,31 @@ +# Oracle Spring Boot Sample for JSON Relational Duality Views + +This sample application demonstrates how to use the Oracle Spring Boot Starter JSON Collections with [JSON Relational Duality Views](https://docs.oracle.com/en/database/oracle/oracle-database/23/jsnvu/overview-json-relational-duality-views.html) + +The Oracle Spring Boot Sample for JSON Relational Duality Views package includes the following components to demonstrate development with JSON Relational Duality Views from a Spring Boot Java context: + +- Entities for JSON Relational Duality Views (Student, Enrollment, Course, Lecture Hall) +- Services to interact with the JSON Relational Duality Views +- A SQL script that initializes the database, including the JSON Relational Duality Views. +- A comprehensive test that uses Spring Boot services to manipulate data from JSON Relational Duality Views. + +## Run the sample application + +The sample application creates a temporary Oracle Free container database, and requires a docker runtime environment. + +To run the test application, run the following command: + +```shell +mvn test +``` + +## Configure your project to use Oracle JSON Relational Duality Views + +To use Oracle JSON Relational Duality Views from your Spring Boot application, add the following Maven dependency to your project: + +```xml + + com.oracle.database.spring + oracle-spring-boot-starter-json-collections + +``` diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/pom.xml b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/pom.xml new file mode 100644 index 00000000..45bddb30 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/pom.xml @@ -0,0 +1,90 @@ + + + + + 4.0.0 + + oracle-spring-boot-starter-samples + com.oracle.database.spring + 24.2.0 + ../pom.xml + + + oracle-spring-boot-sample-json-duality + 24.2.0 + + Oracle Spring Boot Starter - JSON Relational Duality Views Sample + Oracle Spring Boot Starter Sample for JSON Relational Duality Views + + + Oracle America, Inc. + https://www.oracle.com + + + + + Oracle + obaas_ww at oracle.com + Oracle America, Inc. + https://www.oracle.com + + + + + + The Universal Permissive License (UPL), Version 1.0 + https://oss.oracle.com/licenses/upl/ + repo + + + + + https://github.com/oracle/spring-cloud-oracle + scm:git:https://github.com/oracle/spring-cloud-oracle.git + scm:git:git@github.com:oracle/spring-cloud-oracle.git + + + + + com.oracle.database.spring + oracle-spring-boot-starter-json-collections + ${project.version} + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot-dependencies.version} + test + + + + + org.testcontainers + junit-jupiter + test + + + + org.testcontainers + testcontainers + test + + + + org.testcontainers + oracle-free + test + + + diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Course.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Course.java new file mode 100644 index 00000000..75276b3e --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Course.java @@ -0,0 +1,70 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.util.UUID; + +public class Course { + private String _id; + private String name; + private String description; + private Integer credits; + private LectureHall lecture_hall; + + public static Course createCourse() { + Course course = new Course(); + course.set_id(UUID.randomUUID().toString()); + return course; + } + + public Course() { + } + + public Course(String _id, String name, String description, Integer credits, LectureHall lecture_hall) { + this._id = _id; + this.name = name; + this.description = description; + this.credits = credits; + this.lecture_hall = lecture_hall; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getCredits() { + return credits; + } + + public void setCredits(Integer credits) { + this.credits = credits; + } + + public LectureHall getLecture_hall() { + return lecture_hall; + } + + public void setLecture_hall(LectureHall lecture_hall) { + this.lecture_hall = lecture_hall; + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/CourseService.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/CourseService.java new file mode 100644 index 00000000..9093572a --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/CourseService.java @@ -0,0 +1,38 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.sql.PreparedStatement; +import java.util.List; + +import com.oracle.spring.json.jsonb.JSONB; +import com.oracle.spring.json.jsonb.JSONBRowMapper; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Component; + +@Component +public class CourseService { + private static final String byName = """ + select * from courses_dv v + where v.data.name = ? + """; + + private final JdbcTemplate jdbcTemplate; + private final JSONB jsonb; + private final RowMapper rowMapper; + + public CourseService(JdbcTemplate jdbcTemplate, JSONB jsonb) { + this.jdbcTemplate = jdbcTemplate; + this.jsonb = jsonb; + rowMapper = new JSONBRowMapper<>(jsonb, Course.class); + } + + public List getCourseByName(String name) { + return jdbcTemplate.query(con -> { + PreparedStatement ps = con.prepareStatement(byName); + ps.setString(1, name); + return ps; + }, rowMapper); + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Enrollment.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Enrollment.java new file mode 100644 index 00000000..e727c8f4 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Enrollment.java @@ -0,0 +1,39 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.util.UUID; + +public class Enrollment { + private String _id; + private Course course; + + public Enrollment createEnrollment() { + Enrollment enrollment = new Enrollment(); + enrollment.set_id(UUID.randomUUID().toString()); + return enrollment; + } + + public Enrollment() {} + + public Enrollment(String _id, Course course) { + this._id = _id; + this.course = course; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplication.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplication.java new file mode 100644 index 00000000..a92179f0 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplication.java @@ -0,0 +1,14 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +@SpringBootApplication +public class JSONDualitySampleApplication { + public static void main(String[] args) { + SpringApplication.run(JSONDualitySampleApplication.class, args); + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/LectureHall.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/LectureHall.java new file mode 100644 index 00000000..4d6b157a --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/LectureHall.java @@ -0,0 +1,39 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.util.UUID; + +public class LectureHall { + private String _id; + private String name; + + public static LectureHall createLecureHall() { + LectureHall hall = new LectureHall(); + hall.set_id(UUID.randomUUID().toString()); + return hall; + } + + public LectureHall() {} + + public LectureHall(String _id, String name) { + this._id = _id; + this.name = name; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Student.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Student.java new file mode 100644 index 00000000..cc3027bb --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/Student.java @@ -0,0 +1,101 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.util.List; +import java.util.UUID; + + +public class Student { + private String _id; + private String first_name; + private String last_name; + private String email; + private String major; + private double gpa; + private double credits; + private List enrollments; + + public static Student createStudent() { + Student student = new Student(); + student.set_id(UUID.randomUUID().toString()); + return student; + } + + public Student() {} + + public Student(String _id, String first_name, String last_name, String email, String major, double gpa, double credits, List enrollments) { + this._id = _id; + this.first_name = first_name; + this.last_name = last_name; + this.email = email; + this.major = major; + this.gpa = gpa; + this.credits = credits; + this.enrollments = enrollments; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + public String getFirst_name() { + return first_name; + } + + public void setFirst_name(String first_name) { + this.first_name = first_name; + } + + public String getLast_name() { + return last_name; + } + + public void setLast_name(String last_name) { + this.last_name = last_name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getMajor() { + return major; + } + + public void setMajor(String major) { + this.major = major; + } + + public double getGpa() { + return gpa; + } + + public void setGpa(double gpa) { + this.gpa = gpa; + } + + public double getCredits() { + return credits; + } + + public void setCredits(double credits) { + this.credits = credits; + } + + public List getEnrollments() { + return enrollments; + } + + public void setEnrollments(List enrollments) { + this.enrollments = enrollments; + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/StudentService.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/StudentService.java new file mode 100644 index 00000000..d552d9fa --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/java/com/oracle/database/spring/jsonduality/StudentService.java @@ -0,0 +1,82 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.sql.PreparedStatement; +import java.util.List; +import java.util.UUID; + +import com.oracle.spring.json.jsonb.JSONB; +import com.oracle.spring.json.jsonb.JSONBRowMapper; +import oracle.jdbc.OracleTypes; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +@Component +public class StudentService { + private static final String queryStudents = """ + select * from students_dv + """; + private static final String insertStudent = """ + insert into students_dv (data) values (?) + """; + private static final String updateStudent = """ + update students_dv v set data = ? + where v.data."_id" = ? + """; + private static final String byName = """ + select * from students_dv v + where v.data.first_name = ? + and v.data.last_name = ? + """; + + private final JdbcTemplate jdbcTemplate; + private final JSONB jsonb; + private final RowMapper rowMapper; + + + public StudentService(JdbcTemplate jdbcTemplate, JSONB jsonb) { + this.jdbcTemplate = jdbcTemplate; + this.jsonb = jsonb; + rowMapper = new JSONBRowMapper<>(this.jsonb, Student.class); + } + + public String addStudent(Student student) { + if (!StringUtils.hasText(student.get_id())) { + student.set_id(UUID.randomUUID().toString()); + } + jdbcTemplate.update(con -> { + PreparedStatement ps = con.prepareStatement(insertStudent); + byte[] oson = jsonb.toOSON(student); + ps.setObject(1, oson, OracleTypes.JSON); + return ps; + }); + return student.get_id(); + } + + public void updateStudent(Student student) { + jdbcTemplate.update(con -> { + PreparedStatement ps = con.prepareStatement(updateStudent); + byte[] oson = jsonb.toOSON(student); + ps.setObject(1, oson, OracleTypes.JSON); + ps.setString(2, student.get_id()); + return ps; + }); + } + + public List getStudentByName(String firstName, String lastName) { + RowMapper rowMapper = new JSONBRowMapper<>(jsonb, Student.class); + return jdbcTemplate.query(con -> { + PreparedStatement ps = con.prepareStatement(byName); + ps.setString(1, firstName); + ps.setString(2, lastName); + return ps; + }, rowMapper); + } + + public List getStudents() { + return jdbcTemplate.query(queryStudents, rowMapper); + } +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/resources/application.yaml b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/resources/application.yaml new file mode 100644 index 00000000..e39db064 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/main/resources/application.yaml @@ -0,0 +1,20 @@ +spring: + jpa: + hibernate: + ddl-auto: none + datasource: + username: ${USERNAME} + password: ${PASSWORD} + url: ${JDBC_URL} + + # Set these to use UCP over Hikari. + driver-class-name: oracle.jdbc.OracleDriver + type: oracle.ucp.jdbc.PoolDataSourceImpl + oracleucp: + initial-pool-size: 1 + min-pool-size: 1 + max-pool-size: 30 + connection-pool-name: UCPSampleApplication + connection-factory-class-name: oracle.jdbc.pool.OracleDataSource +server: + port: 9001 diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplicationTest.java b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplicationTest.java new file mode 100644 index 00000000..7af9e1c5 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/java/com/oracle/database/spring/jsonduality/JSONDualitySampleApplicationTest.java @@ -0,0 +1,106 @@ +// Copyright (c) 2024, Oracle and/or its affiliates. +// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. +package com.oracle.database.spring.jsonduality; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; +import org.springframework.test.context.jdbc.Sql; +import org.testcontainers.junit.jupiter.Container; +import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.oracle.OracleContainer; + +import static org.assertj.core.api.Assertions.assertThat; + +@Testcontainers +@SpringBootTest +@Sql("/init.sql") // Initialize the tables and duality views +public class JSONDualitySampleApplicationTest { + /** + * The Testcontainers Oracle Free module let's us create an Oracle database container in a junit context. + */ + @Container + static OracleContainer oracleContainer = new OracleContainer("gvenzl/oracle-free:23.5-slim-faststart") + .withStartupTimeout(Duration.ofMinutes(2)) + .withUsername("testuser") + .withPassword(("testpwd")); + + /** + * Dynamically configure Spring Boot properties to use the Testcontainers database. + */ + @DynamicPropertySource + static void properties(DynamicPropertyRegistry registry) { + registry.add("JDBC_URL", oracleContainer::getJdbcUrl); + registry.add("USERNAME", oracleContainer::getUsername); + registry.add("PASSWORD", oracleContainer::getPassword); + } + + @Autowired + StudentService studentService; + + @Autowired + CourseService courseService; + + @Test + void jsonDualityViewsSampleApplication() { + // fetch courses + List courseByName = courseService.getCourseByName("Introduction to Computer Science"); + assertThat(courseByName).hasSize(1); + Course introToCS = courseByName.get(0); + courseByName = courseService.getCourseByName("Data Structures and Algorithms"); + assertThat(courseByName).hasSize(1); + Course dsAndAlgo = courseByName.get(0); + + + // Enroll existing student in a new course + Student aliceSmith = getStudent("Alice", "Smith"); + Enrollment introToCSEnrollment = new Enrollment(); + introToCSEnrollment.setCourse(introToCS); + List enrollments = new ArrayList<>(); + enrollments.add(introToCSEnrollment); + aliceSmith.setEnrollments(enrollments); + studentService.updateStudent(aliceSmith); + + // Verify enrollment is added + aliceSmith = getStudent("Alice", "Smith"); + List asEnrollments = aliceSmith.getEnrollments(); + assertThat(asEnrollments).hasSize(1); + assertThat(asEnrollments.get(0).getCourse().getName()) + .isEqualTo(introToCS.getName()); + assertThat(asEnrollments.get(0).getCourse().getLecture_hall().getName()) + .isEqualTo("Hoffman Hall"); + + // Create a new student with two enrollments + Student bobSwanson = new Student(); + bobSwanson.setFirst_name("Robert"); + bobSwanson.setLast_name("Swanson"); + bobSwanson.setMajor("Electrical Engineering"); + bobSwanson.setEmail("bob.swanson@xyz.edu"); + bobSwanson.setCredits(44); + bobSwanson.setGpa(3.33); + + Enrollment dsAndAlgoEnrollment = new Enrollment(); + dsAndAlgoEnrollment.setCourse(dsAndAlgo); + bobSwanson.setEnrollments(List.of(introToCSEnrollment, dsAndAlgoEnrollment)); + studentService.addStudent(bobSwanson); + + // Verify student created with enrollments + bobSwanson = getStudent("Robert", "Swanson"); + assertThat(bobSwanson.getEnrollments()).hasSize(2); + } + + private Student getStudent(String firstName, String lastName) { + List studentByName = studentService.getStudentByName(firstName, lastName); + assertThat(studentByName).hasSize(1); + return studentByName.get(0); + } + + +} diff --git a/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/resources/init.sql b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/resources/init.sql new file mode 100644 index 00000000..52f32967 --- /dev/null +++ b/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality/src/test/resources/init.sql @@ -0,0 +1,95 @@ +create table students ( + id varchar2(36) default sys_guid() primary key, + first_name varchar2(50) not null, + last_name varchar2(50) not null, + email varchar2(100), + major varchar2(50) not null, + credits number(10), + gpa binary_double +); + +create table lecture_halls ( + id varchar2(36) default sys_guid() primary key, + name varchar2(50) not null +); + +create table courses ( + id varchar2(36) default sys_guid() primary key, + lecture_hall_id varchar2(36) not null, + name varchar2(50) not null, + description varchar2(250) not null, + credits number check (credits between 0 and 10), + constraint lecture_hall_fk foreign key (lecture_hall_id) + references lecture_halls(id) +); + +create table enrollments ( + id varchar2(36) default sys_guid() primary key, + student_id varchar2(36) not null, + course_id varchar2(36) not null, + constraint student_fk foreign key (student_id) + references students(id), + constraint course_fk foreign key (course_id) + references courses(id) +); + +insert into students (first_name, last_name, email, major, credits, gpa) +values ('Alice', 'Smith', 'alice.smith@example.edu', 'Computer Science', 77, 3.86); +insert into lecture_halls (name) +values ('Hoffman Hall'); +insert into courses (lecture_hall_id, name, description, credits) +values ( + (select id from lecture_halls where name = 'Hoffman Hall'), + 'Introduction to Computer Science', + 'A foundational course covering basic principles of computer science and programming.', + 4 + ); +insert into courses (lecture_hall_id, name, description, credits) +values ( + (select id from lecture_halls where name = 'Hoffman Hall'), + 'Data Structures and Algorithms', + 'An in-depth study of various data structures and fundamental algorithms in computer science.', + 5 + ); + + +create or replace json relational duality view +students_dv as +students @insert @update @delete { + _id : id, + first_name, + last_name, + email, + major, + gpa, + credits, + enrollments : enrollments @insert @update @delete + { + _id : id, + course : courses @insert @update { + _id : id, + name, + description, + credits, + lecture_hall: lecture_halls @insert @update { + _id: id, + name + } + } + } +}; + +create or replace json relational duality view +courses_dv as +courses @insert @update @delete { + _id : id, + name, + description, + credits, + lecture_hall: lecture_halls @insert @update { + _id: id, + name + } +} +/ + diff --git a/database/starters/oracle-spring-boot-starter-samples/pom.xml b/database/starters/oracle-spring-boot-starter-samples/pom.xml index 28511b6c..b95d0fe6 100644 --- a/database/starters/oracle-spring-boot-starter-samples/pom.xml +++ b/database/starters/oracle-spring-boot-starter-samples/pom.xml @@ -50,6 +50,7 @@ oracle-spring-boot-sample-ucp-jpa + oracle-spring-boot-sample-json-duality