generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Ojdbc provider jackson oson #118
Open
fmeheust
wants to merge
6
commits into
main
Choose a base branch
from
ojdbc-provider-jackson-oson
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a4a3b9
Add oson provider source and tests
BidyadharM 864167f
Merge branch 'refs/heads/main' into ojdbc-provider-jackson-oson
BidyadharM f5738d8
Update JDK to 11
fmeheust 8364d47
Fix tests runs
BidyadharM d9a5601
Fix Encoding Test.
BidyadharM 94317cc
Update Jackson version and cleaned up pom dependencies and parameters
fmeheust File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# OSON Provider for Jackson | ||
## Overview | ||
The **OSON Provider for Jackson** is a module that provides support for serializing and deserializing Oracle JSON (OSON) data using Jackson APIs. | ||
It includes custom generators, parsers, serializers, and deserializers for POJO mapping and Java types, ensuring efficient | ||
JSON data handling in Oracle environments. | ||
The module implements [**oracle.jdbc.spi.JsonProvider**](https://docs.oracle.com/en/database/oracle/oracle-database/23/jajdb/oracle/jdbc/spi/OsonProvider.html) | ||
in order to use the Oracle JDBC driver's JSON processing capabilities. It, therefore, requires the **23.6** JDBC Thin Driver (or higher). | ||
## Features | ||
- **OSON Generators**: Custom logic for generating Oracle JSON (OSON) representations of Java objects. | ||
- **OSON Parsers**: Parsing Oracle-specific JSON(OSON bytes) data into Java objects. | ||
- **Serializers**: Custom serializers for transforming Java types into OSON bytes. | ||
- **Deserializers**: Custom deserializers for mapping OSON bytes back into Java POJOs. | ||
- **POJO Mapping**: Seamless mapping between Plain Old Java Objects (POJOs) and Oracle OSON formats. | ||
- **Java Types Handling**: Support for various complex and basic Java types during serialization and deserialization. | ||
- **Jackson Annotation support**: Support for Jackson Annotations. Note: When **@Format** annotation is used, the values are processed as Strings. | ||
|
||
## Installation | ||
|
||
All providers in this module are distributed as single jar on the Maven Central | ||
Repository. The jar is compiled for JDK 8, and is forward compatible with later | ||
JDK versions. The coordinates for the latest release are: | ||
```xml | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-jackson-oson</artifactId> | ||
<version>1.0.1</version> | ||
</dependency> | ||
``` | ||
## Building the provider module | ||
1. Clone the repository: | ||
```bash | ||
git clone https://github.com/oracle/ojdbc-extensions.git | ||
2. Navigate to the project directory: | ||
```bash | ||
cd ojdbc-provider-jackson-oson | ||
3. Build the module and it's dependencies: | ||
```bash | ||
mvn clean -pl ojdbc-provider-jackson-oson -amd install | ||
|
||
## Usage | ||
Usage Examples for Oracle Jackson OSON Provider Extensions can be found at [ojdbc-provider-samples](../ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample) | ||
|
||
## Samples Explanation | ||
- **[AccessJsonColumnUsingPOJOAndJsonProvider](../ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/AccessJsonColumnUsingPOJOAndJsonProvider.java)**: | ||
Demonstrates the usage of the Jackson OSON provider to serialize a Plain Old Java Object (POJO) to OSON | ||
bytes in order to save it in a JSON column in the database and deserialize OSON bytes to | ||
POJO during retrieval. In this case, the JDBC Thin Driver invokes the provider to serialize/deserialize. | ||
- **[AccessJsonColumnUsingHibernate](../ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/AccessJsonColumnUsingHibernate.java)**: | ||
Performs the same task as above using Hibernate. | ||
- **[AccessJsonColumnUsingJacksonObjectNode](../ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/AccessJsonColumnUsingJacksonObjectNode.java)**: | ||
Demonstrates the usage of the Jackson OSON provider to serialize Jackson's ObjectNode | ||
to OSON bytes for insertion and vice-versa for retrieval. | ||
- **[AccessJsonColumnUsingPOJO](../ojdbc-provider-samples/src/main/java/oracle/jdbc/provider/oson/sample/AccessJsonColumnUsingPOJO.java)**: | ||
Demonstrates how to use the Jackson OSON provider APIs to Serialize/Deserialize POJO and use JDBC | ||
to directly insert the OSON bytes. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
################################################################################ | ||
# Copyright (c) 2024 Oracle and/or its affiliates. | ||
# | ||
# The Universal Permissive License (UPL), Version 1.0 | ||
# | ||
# Subject to the condition set forth below, permission is hereby granted to any | ||
# person obtaining a copy of this software, associated documentation and/or data | ||
# (collectively the "Software"), free of charge and under any and all copyright | ||
# rights in the Software, and any and all patent rights owned or freely | ||
# licensable by each licensor hereunder covering either (i) the unmodified | ||
# Software as contributed to or provided by such licensor, or (ii) the Larger | ||
# Works (as defined below), to deal in both | ||
# | ||
# (a) the Software, and | ||
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if | ||
# one is included with the Software (each a "Larger Work" to which the Software | ||
# is contributed by such licensors), | ||
# | ||
# without restriction, including without limitation the rights to copy, create | ||
# derivative works of, display, perform, and distribute the Software and make, | ||
# use, sell, offer for sale, import, export, have made, and have sold the | ||
# Software and the Larger Work(s), and to sublicense the foregoing rights on | ||
# either these or other terms. | ||
# | ||
# This license is subject to the following condition: | ||
# The above copyright notice and either this complete permission notice or at | ||
# a minimum a reference to the UPL must be included in all copies or | ||
# substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
################################################################################ | ||
|
||
# This file provides examples of properties that configure tests in this | ||
# module. | ||
# | ||
# QUICK GUIDE TO RUNNING TESTS: | ||
# 1. Create a copy of this file named "test.properties": | ||
# cp example-test.properties test.properties | ||
# 2. In test.properties, replace example values with real values (the file is | ||
# .gitignore'd, so sensitive info won't be checked in to the repo) | ||
# 3. Comment out any lines for which a value can not be provided (tests are | ||
# skipped if no value is configured). | ||
# 4. mvn clean verify | ||
# | ||
# CONFIGURING TEST PROPERTIES | ||
# Test properties are read from a properties file by the TestProperties class. | ||
# The TestProperties class can be found in: | ||
# ojdbc-provider-common/src/testFixtures/java/oracle/jdbc/provider/TestProperties.java | ||
# The default behavior of TestProperties is to read a file named | ||
# "test.properties" in the current directory. A non-default location may be | ||
# specified as a JVM system property: | ||
# mvn clean verify -Doracle.jdbc.provider.TestProperties=/path/to/my-test.properties | ||
# | ||
# MAINTAINING THIS FILE | ||
# Project maintainers should add an example to this file anytime they write a | ||
# test which requires a new property. Not doing so will inflict pain and | ||
# suffering upon our fellow programmers, and will also lead to increased | ||
# maintenance costs. | ||
# | ||
# IGNORING UNCONFIGURED PROPERTIES | ||
# No test should cause a build failure due to an unconfigured property. | ||
# Using JUnit terminology: A test should "abort" rather than "fail" when a | ||
# property is not configured. This means that the test does not pass, but it | ||
# does not cause the build to fail either. | ||
# Methods of the TestProperties class will automatically abort a test if a | ||
# property is not configured. The org.junit.jupiter.api.Assumptions class may | ||
# also be used directly to abort a test. | ||
# There is NO environment in which ALL tests can be run. Some tests may | ||
# require authentication as a managed identity in an Azure VM, while other | ||
# tests require authentication as an instance principal in an OCI compute | ||
# instance; These environments are mutually exclusive. This is one reason why | ||
# tests can not fail the build if a required property is not set. | ||
# A more practical reason is that developers may not need to run all tests if | ||
# their changes are isolated to single module. For instance, a developer | ||
# working on an OCI provider should not need to set up an Azure tenancy to test | ||
# their changes. | ||
|
||
JACKSON_OSON_URL=url | ||
JACKSON_OSON_USERNAME=user_name | ||
JACKSON_OSON_PASSWORD=pass_word |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>Oracle Jackson OSON Provider</name> | ||
|
||
<parent> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-extensions</artifactId> | ||
<version>${extensions-version}</version> | ||
</parent> | ||
|
||
<artifactId>ojdbc-provider-jackson-oson</artifactId> | ||
<properties> | ||
<jackson-version>2.18.1</jackson-version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-common</artifactId> | ||
<version>${extensions-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc8</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>${jackson-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>${jackson-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-annotations</artifactId> | ||
<version>${jackson-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-jsr310</artifactId> | ||
<version>${jackson-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.oracle.database.jdbc</groupId> | ||
<artifactId>ojdbc-provider-common</artifactId> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>${project.artifactId}</artifactId> | ||
<version>${project.version}</version> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice README. It would be great if you could include a definition of the type mappings, i.e. a table with one column that lists Java types and the default OSON mapping.
Also if I want to override a mapping for some field and gain access to the underlying OracleJsonParser and OracleJsonGenerator is this possible?