diff --git a/database/starters/oracle-spring-boot-starter-json-collections/pom.xml b/database/starters/oracle-spring-boot-starter-json-collections/pom.xml index f93c086c..e22e0c26 100644 --- a/database/starters/oracle-spring-boot-starter-json-collections/pom.xml +++ b/database/starters/oracle-spring-boot-starter-json-collections/pom.xml @@ -59,11 +59,6 @@ spring-boot-starter-jdbc - - com.oracle.database.soda - orajsoda - - jakarta.json jakarta.json-api diff --git a/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/JsonCollectionsAutoConfiguration.java b/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/JsonCollectionsAutoConfiguration.java index b456fc11..0c454bf3 100644 --- a/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/JsonCollectionsAutoConfiguration.java +++ b/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/JsonCollectionsAutoConfiguration.java @@ -3,10 +3,7 @@ package com.oracle.spring.json; import com.oracle.spring.json.jsonb.JSONB; -import com.oracle.spring.json.jsonb.SODA; import jakarta.json.bind.JsonbBuilder; -import oracle.soda.OracleDocument; -import oracle.soda.rdbms.OracleRDBMSClient; import oracle.sql.json.OracleJsonFactory; import org.eclipse.yasson.YassonJsonb; import org.springframework.boot.autoconfigure.AutoConfiguration; @@ -27,21 +24,9 @@ YassonJsonb yassonJsonb() { return (YassonJsonb) JsonbBuilder.create(); } - @Bean - @ConditionalOnClass(OracleRDBMSClient.class) - OracleRDBMSClient oracleRDBMSClient() { - return new OracleRDBMSClient(); - } - @Bean @ConditionalOnClass({OracleJsonFactory.class, YassonJsonb.class}) public JSONB jsonb(OracleJsonFactory oracleJsonFactory, YassonJsonb yassonJsonb) { return new JSONB(oracleJsonFactory, yassonJsonb); } - - @Bean - @ConditionalOnClass({OracleJsonFactory.class, YassonJsonb.class, OracleDocument.class}) - public SODA soda(OracleJsonFactory oracleJsonFactory, YassonJsonb yassonJsonb) { - return new SODA(oracleJsonFactory, yassonJsonb); - } } diff --git a/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/jsonb/SODA.java b/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/jsonb/SODA.java deleted file mode 100644 index 597a0857..00000000 --- a/database/starters/oracle-spring-boot-starter-json-collections/src/main/java/com/oracle/spring/json/jsonb/SODA.java +++ /dev/null @@ -1,41 +0,0 @@ -// 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.spring.json.jsonb; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import jakarta.json.stream.JsonGenerator; -import jakarta.json.stream.JsonParser; -import oracle.soda.OracleDatabase; -import oracle.soda.OracleDocument; -import oracle.soda.OracleException; -import oracle.sql.json.OracleJsonFactory; -import org.eclipse.yasson.YassonJsonb; - -public class SODA { - private final OracleJsonFactory oracleJsonFactory; - private final YassonJsonb jsonb; - - public SODA(OracleJsonFactory oracleJsonFactory, YassonJsonb jsonb) { - this.oracleJsonFactory = oracleJsonFactory; - this.jsonb = jsonb; - } - - public T fromDocument(OracleDocument document, Class clazz) throws OracleException { - JsonParser parser = document.getContentAs(JsonParser.class); - return jsonb.fromJson(parser, clazz); - } - - public OracleDocument toDocument(OracleDatabase oracleDatabase, Object object) throws OracleException { - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { - JsonGenerator gen = oracleJsonFactory.createJsonBinaryGenerator(outputStream) - .wrap(JsonGenerator.class); - jsonb.toJson(object, gen); - gen.close(); - return oracleDatabase.createDocumentFrom(outputStream.toByteArray()); - } catch (IOException e) { - throw new OracleException(e); - } - } -} diff --git a/database/starters/oracle-spring-boot-starter-json-collections/src/test/java/com/oracle/spring/json/JsonCollectionsIT.java b/database/starters/oracle-spring-boot-starter-json-collections/src/test/java/com/oracle/spring/json/JsonCollectionsIT.java index 51029cd0..8f0c368e 100644 --- a/database/starters/oracle-spring-boot-starter-json-collections/src/test/java/com/oracle/spring/json/JsonCollectionsIT.java +++ b/database/starters/oracle-spring-boot-starter-json-collections/src/test/java/com/oracle/spring/json/JsonCollectionsIT.java @@ -3,7 +3,6 @@ package com.oracle.spring.json; import javax.sql.DataSource; -import java.sql.Connection; import java.sql.PreparedStatement; import java.time.Duration; import java.util.List; @@ -11,14 +10,9 @@ import com.oracle.spring.json.jsonb.JSONB; import com.oracle.spring.json.jsonb.JSONBRowMapper; -import com.oracle.spring.json.jsonb.SODA; import com.oracle.spring.json.test.Student; import com.oracle.spring.json.test.StudentDetails; import oracle.jdbc.OracleTypes; -import oracle.soda.OracleCollection; -import oracle.soda.OracleDatabase; -import oracle.soda.OracleDocument; -import oracle.soda.rdbms.OracleRDBMSClient; import oracle.ucp.jdbc.PoolDataSource; import oracle.ucp.jdbc.PoolDataSourceFactory; import org.junit.jupiter.api.BeforeAll; @@ -45,21 +39,12 @@ public class JsonCollectionsIT { @Autowired JSONB jsonb; - @Autowired - SODA soda; - @Autowired - OracleRDBMSClient client; Student student1 = new Student(Student.newId(), "Bob", new StudentDetails( "Computer Science", 3.33, 64 )); - Student student2 = new Student(Student.newId(), "Alice", new StudentDetails( - "Mathematics", - 3.8, - 80 - )); @BeforeAll static void setUp() throws Exception { @@ -95,25 +80,4 @@ create table student ( assertThat(students).hasSize(1); assertThat(students.get(0)).isEqualTo(student1); } - - @Test - void sodaMapping() throws Exception { - try (Connection conn = dataSource.getConnection()) { - OracleDatabase db = client.getDatabase(conn); - db.admin().createCollection("student_soda"); - OracleCollection col = db.openCollection("student_soda"); - - OracleDocument document1 = soda.toDocument(db, student1); - OracleDocument document2 = soda.toDocument(db, student2); - - col.insert(document1); - col.insert(document2); - - OracleDocument found = col.find().filter("{\"name\":\"Alice\"}") - .getOne(); - - Student student = soda.fromDocument(found, Student.class); - assertThat(student).isEqualTo(student2); - } - } }