Skip to content

Commit 662ceab

Browse files
Merge pull request #28 from oracle/18-spi-0-9-0-update
18 spi 0 9 0 update
2 parents 527b7e1 + e0426a9 commit 662ceab

32 files changed

+4108
-1936
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target/
22
.DS_Store
3+
*.iml
34
/src/test/resources/config.properties
45
/sample/.gradle/
56
/sample/build/

README.md

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,37 @@ The Oracle R2DBC Driver is a Java library that supports reactive programming wit
44

55
Oracle R2DBC implements the R2DBC Service Provider Interface (SPI) as specified by the Reactive Relational Database Connectivity (R2DBC) project. The R2DBC SPI exposes Reactive Streams as an abstraction for remote database operations. Reactive Streams is a well defined standard for asynchronous, non-blocking, and back-pressured communication. This standard allows an R2DBC driver to interoperate with other reactive libraries and frameworks, such as Spring, Project Reactor, RxJava, and Akka Streams.
66

7-
Oracle R2DBC 0.1.0 is the initial release of this driver. Release numbers follow the [Semantic Versioning](https://semver.org) specification. As indicated by the major version number of 0, this is a development release in which the behavior implemented for any API may change.
87

98
### Learn More About R2DBC:
109
[R2DBC Project Home Page](https://r2dbc.io)
1110

12-
[R2DBC Javadocs v0.8.2](https://r2dbc.io/spec/0.8.2.RELEASE/api/)
11+
[R2DBC Javadocs v0.9.0.M1](https://r2dbc.io/spec/0.9.0.M1/api/)
1312

14-
[R2DBC Specification v0.8.2](https://r2dbc.io/spec/0.8.2.RELEASE/spec/html/)
13+
[R2DBC Specification v0.9.0.M1](https://r2dbc.io/spec/0.9.0.M1/spec/html/)
1514

1615
### Learn More About Reactive Streams:
1716
[Reactive Streams Project Home Page](http://www.reactive-streams.org)
1817

1918
[Reactive Streams Javadocs v1.0.3](http://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/org/reactivestreams/package-summary.html)
2019

2120
[Reactive Streams Specification v1.0.3](https://github.com/reactive-streams/reactive-streams-jvm/blob/v1.0.3/README.md)
21+
# About This Version
22+
Oracle R2DBC 0.2.0 updates the implemented SPI version to 0.9.0.M1. With the
23+
0.9.0.M1 SPI update, Oracle R2DBC 0.2.0 introduces support for procedural
24+
calls (PL/SQL), the ```Statement.bind(...)``` methods are enhanced to accept
25+
```io.r2dbc.spi.Parameter``` objects, and the
26+
```Connection.beginTransaction(TransactionDefintion)``` method is
27+
implemented to support named and read-only/read-write transactions.
28+
29+
# Performance Goals
30+
The primary goal of these early releases of Oracle R2DBC is to support the R2DBC
31+
SPI on Oracle Database. The only performance goal is to enable concurrent
32+
database calls to be executed by a single thread.
33+
34+
The R2DBC SPI and Oracle's implementation are both pre-production. As these
35+
projects mature we will shift our development focus from implementing
36+
the SPI to optimizing the implementation.
37+
2238

2339
# Installation
2440
Oracle R2DBC can be built from source using Maven:
@@ -37,7 +53,7 @@ Artifacts can also be found on Maven Central.
3753
```
3854

3955
Oracle R2DBC is compatible with JDK 11 (or newer), and has the following runtime dependencies:
40-
- R2DBC SPI 0.8.2
56+
- R2DBC SPI 0.9.0.M1
4157
- Reactive Streams 1.0.3
4258
- Project Reactor 3.0.0
4359
- Oracle JDBC 21.1.0.0 for JDK 11 (ojdbc11.jar)
@@ -112,8 +128,8 @@ This document specifies the behavior of the R2DBC SPI implemented for the
112128
Oracle Database. This SPI implementation is referred to as the "Oracle R2DBC
113129
Driver" or "Oracle R2DBC" throughout the remainder of this document.
114130

115-
The Oracle R2DBC Driver implements behavior specified by the R2DBC 0.8.2
116-
[Specification](https://r2dbc.io/spec/0.8.2.RELEASE/spec/html/)
131+
The Oracle R2DBC Driver implements behavior specified by the R2DBC 0.9.0.M1
132+
[Specification](https://r2dbc.io/spec/0.9.0.M1/spec/html/)
117133
and [Javadoc](https://r2dbc.io/spec/0.8.3.RELEASE/api/)
118134

119135
Publisher objects created by Oracle R2DBC implement behavior specified by
@@ -190,6 +206,8 @@ or Oracle JDBC Driver error message](https://docs.oracle.com/en/database/oracle/
190206
- READ COMMITTED is the default transaction isolation level, and is the
191207
only level supported in this release.
192208
- Transaction savepoints are not supported in this release.
209+
- TransactionDefinition.LOCK_WAIT_TIMEOUT is not supported in this release.
210+
- Oracle Database does not support a lock wait timeout that applies to all statements within a transaction.
193211

194212
### Statements
195213
- Batch execution is only supported for DML type SQL commands (INSERT/UPDATE/DELETE).
@@ -220,6 +238,36 @@ values for a non-empty set of column names.
220238
- INSERT: https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/INSERT.html#GUID-903F8043-0254-4EE9-ACC1-CB8AC0AF3423
221239
- UPDATE: https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/UPDATE.html#GUID-027A462D-379D-4E35-8611-410F3AC8FDA5
222240

241+
### Procedural Calls
242+
- Use ```Connection.createStatement(String)``` to create a
243+
```Statement``` that executes a PL/SQL call:
244+
```java
245+
connection.createStatement("BEGIN sayHello(:name_in, :greeting_out); END;")
246+
```
247+
- Register out parameters by invoking ```Statement.bind(int/String, Object)```
248+
with an instance of ```io.r2dbc.spi.Parameter``` implementing the
249+
```io.r2dbc.spi.Parameter.Out``` marker interface:
250+
```java
251+
statement.bind("greeting_out", Parameters.out(R2dbcType.VARCHAR))
252+
```
253+
- Register in out parameters by invoking
254+
```Statement.bind(int/String, Object)``` with an instance of
255+
```io.r2dbc.spi.Parameter``` implementing both the
256+
```io.r2dbc.spi.Parameter.Out``` and
257+
```io.r2dbc.spi.Parameter.In``` marker interfaces.
258+
- Consume out parameters by invoking
259+
```Result.map(BiFunction<Row, RowMetadata>)```:
260+
```java
261+
result.map((row,metadata) -> row.get("greeting_out", String.class))
262+
```
263+
- ```Statement.execute()``` returns a ```Publisher<Result>``` that emits one
264+
```Result``` for each cursor returned by ```DBMS_SQL.RETURN_RESULT```
265+
- The order in which a ```Result``` is emitted for a cursor
266+
corresponds to the order in which the procedure returns each cursor.
267+
- If a procedure returns cursors and also has out parameters, then the
268+
```Result``` for out parameters is emitted last, after the
269+
```Result``` for each returned cursor.
270+
223271
### Type Mappings
224272
- Blob and Clob objects are the default mapping implemented by Row.get(...) for
225273
BLOB and CLOB columns. ByteBuffer and String mappings are not supported for BLOB

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
<groupId>com.oracle.database.r2dbc</groupId>
2828
<artifactId>oracle-r2dbc</artifactId>
29-
<version>0.1.0</version>
29+
<version>0.2.0</version>
3030
<name>oracle-r2dbc</name>
3131
<description>
32-
Oracle R2DBC Driver implementing version 0.8.2 of the R2DBC SPI for Oracle Database.
32+
Oracle R2DBC Driver implementing version 0.9.0.M1 of the R2DBC SPI for Oracle Database.
3333
</description>
3434
<url>
3535
https://github.com/oracle/oracle-r2dbc
@@ -66,7 +66,7 @@
6666
<properties>
6767
<java.version>11</java.version>
6868
<ojdbc.version>21.1.0.0</ojdbc.version>
69-
<r2dbc.version>0.8.2.RELEASE</r2dbc.version>
69+
<r2dbc.version>0.9.0.M1</r2dbc.version>
7070
<reactor.version>3.3.0.RELEASE</reactor.version>
7171
<reactive-streams.version>1.0.3</reactive-streams.version>
7272
<junit.version>5.7.0</junit.version>

src/main/java/module-info.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
with oracle.r2dbc.impl.OracleConnectionFactoryProviderImpl;
3131

3232
requires java.sql;
33-
3433
requires ojdbc11;
35-
requires org.reactivestreams;
3634
requires reactor.core;
37-
requires r2dbc.spi;
35+
requires transitive org.reactivestreams;
36+
requires transitive r2dbc.spi;
37+
38+
exports oracle.r2dbc;
3839
}
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
/*
2+
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
3+
4+
This software is dual-licensed to you under the Universal Permissive License
5+
(UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License
6+
2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
7+
either license.
8+
9+
Licensed under the Apache License, Version 2.0 (the "License");
10+
you may not use this file except in compliance with the License.
11+
You may obtain a copy of the License at
12+
13+
https://www.apache.org/licenses/LICENSE-2.0
14+
15+
Unless required by applicable law or agreed to in writing, software
16+
distributed under the License is distributed on an "AS IS" BASIS,
17+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18+
See the License for the specific language governing permissions and
19+
limitations under the License.
20+
*/
21+
package oracle.r2dbc;
22+
23+
import io.r2dbc.spi.Type;
24+
import oracle.sql.json.OracleJsonObject;
25+
26+
import java.nio.ByteBuffer;
27+
import java.sql.RowId;
28+
import java.time.Duration;
29+
import java.time.LocalDateTime;
30+
import java.time.Period;
31+
32+
/**
33+
* SQL types supported by Oracle Database that are not defined as standard types
34+
* by {@link io.r2dbc.spi.R2dbcType}.
35+
*/
36+
public final class OracleR2dbcTypes {
37+
38+
private OracleR2dbcTypes() {}
39+
40+
/**
41+
* A 64-bit, double-precision floating-point number data type.
42+
*/
43+
public static final Type BINARY_DOUBLE =
44+
new TypeImpl(Double.class, "BINARY_DOUBLE");
45+
46+
/**
47+
* A 32-bit, single-precision floating-point number data type.
48+
*/
49+
public static final Type BINARY_FLOAT =
50+
new TypeImpl(Float.class, "BINARY_FLOAT");
51+
52+
/**
53+
* A Binary Large Object (BLOB) as implemented by Oracle Database. The default
54+
* Java type mapping is {@link io.r2dbc.spi.Blob} rather than
55+
* {@link java.nio.ByteBuffer}, which is the mapping of the standard
56+
* {@link io.r2dbc.spi.R2dbcType#BLOB}.
57+
*/
58+
public static final Type BLOB =
59+
new TypeImpl(io.r2dbc.spi.Blob.class, "BLOB");
60+
61+
/**
62+
* A Character Large Object (BLOB) as implemented by Oracle Database. The
63+
* default Java type mapping is {@link io.r2dbc.spi.Clob} rather than
64+
* {@link String}, which is the mapping of the standard
65+
* {@link io.r2dbc.spi.R2dbcType#CLOB}.
66+
*/
67+
public static final Type CLOB =
68+
new TypeImpl(io.r2dbc.spi.Clob.class, "CLOB");
69+
70+
/**
71+
* Stores a period of time in days, hours, minutes, and seconds.
72+
*/
73+
public static final Type INTERVAL_DAY_TO_SECOND =
74+
new TypeImpl(Duration.class, "INTERVAL DAY TO SECOND");
75+
76+
/**
77+
* Stores a period of time in years and months.
78+
*/
79+
public static final Type INTERVAL_YEAR_TO_MONTH =
80+
new TypeImpl(Period.class, "INTERVAL YEAR TO MONTH");
81+
82+
public static final Type JSON =
83+
new TypeImpl(OracleJsonObject.class, "JSON");
84+
85+
/**
86+
* Character data of variable length up to 2 gigabytes.
87+
*/
88+
public static final Type LONG =
89+
new TypeImpl(String.class, "LONG");
90+
91+
/**
92+
* Raw binary data of variable length up to 2 gigabytes.
93+
*/
94+
public static final Type LONG_RAW =
95+
new TypeImpl(ByteBuffer.class, "LONG RAW");
96+
97+
/**
98+
* A National Character Large Object (NCLOB) as implemented by Oracle
99+
* Database. The default Java type mapping is {@link io.r2dbc.spi.Clob}
100+
* rather than {@link String}, which is the mapping of the standard
101+
* {@link io.r2dbc.spi.R2dbcType#NCLOB}.
102+
*/
103+
public static final Type NCLOB =
104+
new TypeImpl(io.r2dbc.spi.Clob.class, "NCLOB");
105+
106+
/**
107+
* Base 64 string representing the unique address of a row in its table.
108+
*/
109+
public static final Type ROWID =
110+
new TypeImpl(RowId.class, "ROWID");
111+
112+
/**
113+
* Timestamp that is converted to the database's timezone when stored, and
114+
* converted to the local timezone (the session timezone) when retrieved.
115+
*/
116+
public static final Type TIMESTAMP_WITH_LOCAL_TIME_ZONE =
117+
new TypeImpl(LocalDateTime.class, "TIMESTAMP WITH LOCAL TIME ZONE");
118+
119+
/**
120+
* Implementation of the {@link Type} SPI.
121+
*/
122+
private static final class TypeImpl implements Type {
123+
124+
/**
125+
* The Java Language mapping of this SQL type.
126+
*/
127+
private final Class<?> javaType;
128+
129+
/**
130+
* The name of this SQL type, as it would appear in a DDL expression.
131+
*/
132+
private final String sqlName;
133+
134+
/**
135+
* Constructs a {@code Type} having a {@code javaType} mapping and
136+
* {@code sqlName}.
137+
* @param javaType Java type
138+
* @param sqlName SQL type name
139+
*/
140+
TypeImpl(Class<?> javaType, String sqlName) {
141+
this.javaType = javaType;
142+
this.sqlName = sqlName;
143+
}
144+
145+
/**
146+
* {@inheritDoc}
147+
* <p>
148+
* Implements the R2DBC SPI method by returning the default Java type
149+
* mapping for values of this SQL type. The Java type returned by this
150+
* method is the type of {@code Object} returned by {@code Row.get
151+
* (String/int)} when accessing a value of this SQL type.
152+
* </p>
153+
*/
154+
@Override
155+
public Class<?> getJavaType() {
156+
return javaType;
157+
}
158+
159+
/**
160+
* {@inheritDoc}
161+
* <p>
162+
* Implements the R2DBC SPI method by returning the name of this SQL type.
163+
* The name returned by this method is recognized in expressions of a SQL
164+
* command, for instance: A column definition of a {@code CREATE TABLE}
165+
* command.
166+
* </p>
167+
*
168+
* @return
169+
*/
170+
@Override
171+
public String getName() {
172+
return sqlName;
173+
}
174+
175+
/**
176+
* Returns the name of this type.
177+
* @return Type name
178+
*/
179+
@Override
180+
public String toString() {
181+
return getName();
182+
}
183+
}
184+
185+
}

0 commit comments

Comments
 (0)