Skip to content

Commit 4f9a07b

Browse files
authored
Merge pull request #262 from eclipse/create-oracle-nosql
Create Oracle NoSQL database support
2 parents 675e912 + 3852132 commit 4f9a07b

File tree

58 files changed

+4069
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4069
-13
lines changed

CHANGELOG.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version
1212

1313
- Update Jakarta Data to version 1.0.0-M3
1414

15+
=== Added
16+
17+
- Include support to Oracle NoSQL database
18+
1519
== [1.0.4] - 2023-12-19
1620

1721
=== Fixed

README.adoc

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,132 @@ Bson filter = eq("name", "Poliana");
10541054
Stream<Person> stream = template.select(Person.class , filter);
10551055
----
10561056

1057+
== Oracle NoSQL
1058+
1059+
image::https://www.jnosql.org/img/logos/oracle.png[Oracle NoSQL Project,align="center"width=25%,height=25%]
1060+
1061+
https://www.oracle.com/database/nosql/technologies/nosql/[Oracle NoSQL Database] is a native multi-model database that provides flexible data models for documents, graphs, and key values. You can develop high-performance applications using a user-friendly SQL-like query language or JavaScript extensions.
1062+
1063+
This API offers support for *Document* and *Key-Value* data types.
1064+
1065+
=== How To Install
1066+
1067+
You can use either the Maven or Gradle dependencies:
1068+
1069+
[source,xml]
1070+
----
1071+
<dependency>
1072+
<groupId>org.eclipse.jnosql.databases</groupId>
1073+
<artifactId>jnosql-oracle-nosql</artifactId>
1074+
<version>1.0.5-SNAPSHOT</version>
1075+
</dependency>
1076+
----
1077+
1078+
=== Configuration
1079+
1080+
This API provides the ```OracleNoSQLConfigurations``` class to programmatically establish the credentials.
1081+
Please note that you can establish properties using the https://microprofile.io/microprofile-config/[MicroProfile Config] specification.
1082+
1083+
[cols="Oracle NoSQL Properties"]
1084+
|===
1085+
| Property Name | Description
1086+
1087+
| `jnosql.oracle.nosql.host` | Specifies the hostname or IP address of the Oracle NoSQL database server.
1088+
1089+
| `jnosql.oracle.nosql.user` | Specifies the username used to authenticate with the Oracle NoSQL database.
1090+
1091+
| `jnosql.oracle.nosql.password` | Specifies the password used to authenticate with the Oracle NoSQL database.
1092+
1093+
| `jnosql.oracle.nosql.table.read.limit` | Specifies the desired throughput of read operations when creating a table using Eclipse JNoSQL.
1094+
1095+
| `jnosql.oracle.nosql.table.write.limit` | Specifies the desired throughput of write operations when creating a table using Eclipse JNoSQL.
1096+
1097+
| `jnosql.oracle.nosql.table.storage.gb` | Specifies the maximum storage, in gigabytes, to be consumed by a table created using Eclipse JNoSQL.
1098+
1099+
| `jnosql.oracle.nosql.table.wait.millis` | Specifies the total amount of time to wait, in milliseconds, when creating a table.
1100+
1101+
| `jnosql.oracle.nosql.table.delay.millis` | Specifies the amount of time to wait, in milliseconds, between polling attempts when creating a table.
1102+
1103+
| `jnosql.oracle.nosql.deployment` | Specifies the deployment type for Oracle NoSQL database.
1104+
1105+
| `jnosql.oracle.nosql.tenant.id` | Specifies the Oracle NoSQL database tenant ID for Cloud deployment.
1106+
1107+
| `jnosql.oracle.nosql.fingerprint` | Specifies the fingerprint for authentication with Oracle NoSQL database for Cloud deployment.
1108+
1109+
| `jnosql.oracle.nosql.private.key` | Specifies the private key for authentication with Oracle NoSQL database for Cloud deployment.
1110+
|===
1111+
1112+
1113+
1114+
This is an example using Oracle NoSQL's Document API with MicroProfile Config.
1115+
1116+
[source,properties]
1117+
----
1118+
jnosql.document.provider=org.eclipse.jnosql.databases.oracle.communication.OracleDocumentConfiguration
1119+
jnosql.document.database=library
1120+
jnosql.oracle.nosql.host=http://localhost:8080
1121+
----
1122+
1123+
This is an example using Oracle NoSQL's Key-Value API with MicroProfile Config.
1124+
1125+
[source,properties]
1126+
----
1127+
jnosql.keyvalue.provider=org.eclipse.jnosql.databases.oracle.communication.OracleNoSQLKeyValueConfiguration
1128+
jnosql.keyvalue.database=library
1129+
jnosql.oracle.nosql.host=http://localhost:8080
1130+
----
1131+
1132+
The config settings are the default behavior; nevertheless, there is an option to do it programmatically. Create a class that implements the `Supplier<ArangoDBDocumentManager>` and then defines it as an `@Alternative` and the `Priority`.
1133+
1134+
[source,java]
1135+
----
1136+
@ApplicationScoped
1137+
@Alternative
1138+
@Priority(Interceptor.Priority.APPLICATION)
1139+
public class ManagerSupplier implements Supplier<OracleNoSQLDocumentManager> {
1140+
1141+
@Produces
1142+
public OracleNoSQLDocumentManager get() {
1143+
Settings settings = Settings.builder().put("credential", "value").build();
1144+
OracleDocumentConfiguration configuration = new OracleDocumentConfiguration();
1145+
OracleDocumentManagerFactory factory = configuration.apply(settings);
1146+
return factory.apply("database");
1147+
}
1148+
}
1149+
----
1150+
1151+
1152+
=== Repository
1153+
1154+
The ```OracleNoSQLRepository``` interface is an extension of the Repository interface that allows execution of SQL via the ```@SQL``` annotation. Also, it's possible to combine with ```@Param``` annotation to execute parameterized SQL queries:
1155+
1156+
[source,java]
1157+
----
1158+
@Repository
1159+
interface PersonRepository extends OracleNoSQLRepository<Person, String> {
1160+
1161+
@SQL("select * from Person")
1162+
List<Person> findAll();
1163+
1164+
@SQL("select * from Person where name = ?")
1165+
List<Person> findByName(@Param("") String name);
1166+
}
1167+
----
1168+
1169+
1170+
=== Template
1171+
1172+
The ```OracleNoSQLTemplate``` interface is a specialization of the ```DocumentTemplate``` interface that allows using synchronous SQL operation.
1173+
1174+
[source,java]
1175+
----
1176+
@Inject
1177+
private OracleNoSQLTemplate template;
1178+
...
1179+
List<Person> people = template.sql("select * from people where people.content.name =?", "Ada");
1180+
----
1181+
1182+
10571183
== OrientDB
10581184

10591185
image::https://jnosql.github.io/img/logos/orientdb.png[Orient Project,align="center" width=25%,height=25%]

jnosql-arangodb/src/test/java/org/eclipse/jnosql/databases/arangodb/mapping/ArangoDBExtensionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ArangoDBExtensionTest {
4141
private PersonRepository repository;
4242

4343
@Test
44-
public void shouldSaveOrientDB() {
44+
public void shouldSave() {
4545
Assertions.assertNotNull(repository);
4646
}
4747
}

jnosql-couchbase/src/main/java/org/eclipse/jnosql/databases/couchbase/communication/DefaultCouchbaseDocumentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public Stream<DocumentEntity> select(final DocumentQuery query) throws NullPoint
174174

175175
if (!n1QLQuery.hasOnlyIds()) {
176176
QueryResult result;
177-
if (n1QLQuery.hasParameter()) {
177+
if (n1QLQuery.isParameterEmpty()) {
178178
result = cluster.query(n1QLQuery.query());
179179
} else {
180180
result = cluster.query(n1QLQuery.query(), QueryOptions

jnosql-couchbase/src/main/java/org/eclipse/jnosql/databases/couchbase/communication/N1QLBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private void appendCondition(StringBuilder n1ql, JsonObject params,
157157
condition(documentCondition, query, params, ids);
158158
if(index == 0){
159159
n1ql.append(" ").append(query);
160-
} else {
160+
} else if(!query.isEmpty()) {
161161
n1ql.append(condition).append(query);
162162
}
163163
index++;

jnosql-couchbase/src/main/java/org/eclipse/jnosql/databases/couchbase/communication/N1QLQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ public List<String> ids() {
2626
return Collections.unmodifiableList(ids);
2727
}
2828

29-
public boolean hasParameter() {
29+
public boolean isParameterEmpty() {
3030
return this.params.isEmpty();
3131
}
3232

3333
public boolean hasOnlyIds() {
34-
return hasIds() && hasParameter();
34+
return hasIds() && isParameterEmpty();
3535
}
3636

3737
public boolean hasIds() {

jnosql-memcached/src/main/java/org/eclipse/jnosql/databases/memcached/communication/MemcachedBucketManagerFactory.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ public void close() {
4242
}
4343

4444
@Override
45-
public Map getMap(String bucketName, Class keyValue, Class valueValue) {
46-
throw new UnsupportedOperationException("This method is not supported");
45+
public <K, V> Map<K, V> getMap(String bucketName, Class<K> keyValue, Class<V> valueValue) {
46+
throw new UnsupportedOperationException("Memcached does not support Map");
4747
}
4848

4949
@Override
50-
public Queue getQueue(String bucketName, Class clazz) {
51-
throw new UnsupportedOperationException("This method is not supported");
50+
public <T> Queue<T> getQueue(String bucketName, Class<T> type) {
51+
throw new UnsupportedOperationException("Memcached does not support queue");
5252
}
5353

5454
@Override
55-
public Set getSet(String bucketName, Class clazz) {
56-
throw new UnsupportedOperationException("This method is not supported");
55+
public <T> Set<T> getSet(String bucketName, Class<T> type) {
56+
throw new UnsupportedOperationException("Memcached does not support set");
5757
}
5858

5959
@Override
60-
public List getList(String bucketName, Class clazz) {
60+
public <T> List<T> getList(String bucketName, Class<T> type) {
6161
throw new UnsupportedOperationException("This method is not supported");
6262
}
6363
}

jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/communication/MongoDBDocumentConfigurationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void shouldCreateDocumentManagerFactoryByMap() {
3939

4040

4141
@Test
42-
void shouldReturnErrorWhendSettingsIsNull() {
42+
void shouldReturnErrorWhenSettingsIsNull() {
4343
DocumentConfiguration configuration = new MongoDBDocumentConfiguration();
4444
assertThrows(NullPointerException.class, () -> configuration.apply(null));
4545
}

jnosql-nosql-oracle/pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) 2022 Contributors to the Eclipse Foundation
4+
~ All rights reserved. This program and the accompanying materials
5+
~ are made available under the terms of the Eclipse Public License v1.0
6+
~ and Apache License v2.0 which accompanies this distribution.
7+
~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
8+
~ and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
9+
~
10+
~ You may elect to redistribute this code under either of these licenses.
11+
~
12+
~ Contributors:
13+
~
14+
~ Otavio Santana
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.eclipse.jnosql.databases</groupId>
22+
<artifactId>jnosql-databases-parent</artifactId>
23+
<version>1.0.5-SNAPSHOT</version>
24+
</parent>
25+
26+
<artifactId>jnosql-oracle-nosql</artifactId>
27+
<description>The Eclipse JNoSQL layer implementation Oracle NoSQL</description>
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.eclipse.jnosql.communication</groupId>
31+
<artifactId>jnosql-communication-key-value</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.eclipse.jnosql.mapping</groupId>
35+
<artifactId>jnosql-mapping-key-value</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.eclipse.jnosql.communication</groupId>
39+
<artifactId>jnosql-communication-document</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.eclipse.jnosql.mapping</groupId>
43+
<artifactId>jnosql-mapping-document</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>com.oracle.nosql.sdk</groupId>
47+
<artifactId>nosqldriver</artifactId>
48+
<version>5.4.14</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>${project.groupId}</groupId>
52+
<artifactId>jnosql-database-commons</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
55+
</dependencies>
56+
57+
</project>

0 commit comments

Comments
 (0)