Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json collections cleanup #144

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

<dependency>
<groupId>com.oracle.database.soda</groupId>
<artifactId>orajsoda</artifactId>
</dependency>

<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@
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;
import java.util.UUID;

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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
}
}
Loading