Skip to content

Commit

Permalink
Further work on Oracle support
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Nov 27, 2016
1 parent e1f9f9f commit d90e895
Show file tree
Hide file tree
Showing 74 changed files with 1,447 additions and 330 deletions.
34 changes: 11 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,20 @@ matrix:
# Oracle
# TODO: work on hibernate/oracle support
# - env: JPAPROVIDER=hibernate RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=hibernate-4.3 RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=hibernate-5.0 RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=hibernate-5.1 RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=hibernate-5.2 RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=oracle
jdk: oraclejdk8
sudo: true
# TODO: work on datanucleus-4/oracle support
# - env: JPAPROVIDER=datanucleus-4 RDBMS=oracle
# jdk: oraclejdk8
Expand All @@ -195,8 +197,10 @@ matrix:
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=eclipselink RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=openjpa RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# JDK 9 - Not going to work until javassist is fixed
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9
Expand All @@ -207,29 +211,13 @@ matrix:
services:
- docker
allow_failures:
# - env: JPAPROVIDER=datanucleus-4 RDBMS=sqlite
# jdk: oraclejdk8
# - env: JPAPROVIDER=datanucleus-5 RDBMS=sqlite
# - env: JPAPROVIDER=datanucleus-4 RDBMS=db2
# sudo: true
# - env: JPAPROVIDER=datanucleus-4 RDBMS=firebird
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=datanucleus-4 RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# - env: JPAPROVIDER=eclipselink RDBMS=h2
# - env: JPAPROVIDER=openjpa RDBMS=h2
# - env: JPAPROVIDER=hibernate RDBMS=firebird
# sudo: true
# - env: JPAPROVIDER=hibernate RDBMS=oracle
# sudo: true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=oracle
jdk: oraclejdk8
sudo: true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=h2 JDK=9
sudo: true
- env: JPAPROVIDER=hibernate-5.2 RDBMS=mssql
jdk: oraclejdk8
sudo: true
services:
- docker
# - env: JPAPROVIDER=hibernate-6.0 RDBMS=h2
# jdk: oraclejdk8
- docker
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,32 @@ WireCrypt = Enabled

After creating the DB with `create database 'localhost:test' user 'sysdba' password 'sysdba';`, you can connect with JDBC with `jdbc:firebirdsql:localhost:test?charSet=utf-8`

## Oracle

When setting up Oracle locally, keep in mind that when you connect to it, you have to set the NLS_SORT to BINARY.
Since the JDBC driver derives values from the locale settings of the JVM, you should set the default locale settings to en_US.
In IntelliJ when defining the Oracle database, go to the Advanced tab an specify the JVM options `-Duser.country=us -Duser.language=en`.

### JDBC Driver

You have to install the JDBC driver manually. If you install Oracle XE locally, you can take it from $ORACLE_HOME/jdbc otherwise download it from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
Copy the jar to $M2_HOME/com/oracle/ojdbc14/10.2.0.4.0/ojdbc14-10.2.0.4.0.jar and you should be good to go.

### Install Oracle locally

Download Oracle XE from http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html
During installation use the password "oracle" which is also the default password for the docker image.

## Website deployment

You can use `build-deploy-website.sh` to deploy to the target environment but need to configure in ~/.m2/settings.xml the following servers.

Id: staging-persistence.blazebit.com
User/Password: user/****

Id: persistence.blazebit.com
User/Password: user/****

Licensing
=========

Expand Down
28 changes: 28 additions & 0 deletions build-deploy-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

if [ "$1" == "" ]; then
echo "Stage (staging, prod) [staging]: "
read input </dev/tty

if [ "$input" == "" ]; then
STAGE="staging"
elif [ "$input" == "prod" ]; then
STAGE="blazebit-release"
else
STAGE=$input
fi
else
STAGE=$1
fi

if [ "$STAGE" == "staging" ]; then
REPO=staging-persistence.blazebit.com
elif [ "$STAGE" == "blazebit-release" ]; then
REPO=persistence.blazebit.com
else
echo "Invalid stage: $STAGE"
exit 1
fi

mvn -P $STAGE --projects website -am clean compile
mvn -P $STAGE --projects website site:deploy -DrepositoryId=$REPO
59 changes: 59 additions & 0 deletions build-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
set -e

DB_HOST=${DOCKER_MACHINE_IP:-192.168.99.100}
ORACLE_USER=${ORACLE_USER:-SYSTEM}
ORACLE_PASSWORD=${ORACLE_PASSWORD:-oracle}

JPA_PROVIDER="$1"
DBMS="$2"
BUILD="$3"
PROPERTIES=

if [ "$JPA_PROVIDER" == "" ]; then
echo "JPA provider (hibernate-4.2, hibernate-4.3, hibernate-5.0, hibernate-5.1, hibernate-5.2, datanucleus-4, datanucleus-5, eclipselink, openjpa) [hibernate-5.2]: "
read input </dev/tty

if [ "$input" == "" ]; then
JPA_PROVIDER="hibernate-5.2"
elif [ "$input" == "hibernate-4.2" ]; then
JPA_PROVIDER="hibernate"
else
JPA_PROVIDER=$input
fi
fi

if [ "$DBMS" == "" ]; then
echo "DBMS (h2, mysql, postgresql, sqlite, db2, firebird, oracle, mssql) [h2]: "
read input </dev/tty

if [ "$input" == "" ]; then
DBMS="h2"
elif [ "$input" == "oracle" ]; then
DBMS=$input
if [ mvn -P oracle help:effective-settings | grep '<id>oracle</id>' == "" ]; then
PROPERTIES="-Djdbc.url=jdbc:oracle:thin:@$DB_HOST:1521/xe -Djdbc.user=$ORACLE_USER -Djdbc.password=$ORACLE_PASSWORD -Duser.country=US -Duser.language=en"
fi
else
DBMS=$input
fi
fi

PROFILES="$JPA_PROVIDER,$DBMS"

if [ "$BUILD" == "" ]; then
echo "BUILD (full, test) [full]: "
read input </dev/tty

if [ "$input" == "" ]; then
BUILD="full"
else
BUILD=$input
fi
fi

if [ "$BUILD" == "test" ]; then
eval exec mvn -P "$PROFILES" --projects "core/testsuite,entity-view/testsuite,jpa-criteria/testsuite" -am clean test $PROPERTIES
else
eval exec mvn -P "$PROFILES" clean test $PROPERTIES
fi
6 changes: 2 additions & 4 deletions build-release-website.sh → build-website.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/bin/bash

if [ "$1" == "" ]; then
echo "Stage (local, prod, staging) [local]: "
echo "Stage (staging, prod) [staging]: "
read input </dev/tty

if [ "$input" == "" ]; then
STAGE="local"
STAGE="staging"
elif [ "$input" == "prod" ]; then
STAGE="blazebit-release"
elif [ "$input" == "staging" ]; then
STAGE="staging"
else
STAGE=$input
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

package com.blazebit.persistence.spi;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -237,4 +241,33 @@ public interface DbmsDialect {
* @since 1.2.0
*/
public String cast(String expression, String sqlType);

/**
* Returns whether sql types for the returning columns need to be provided.
*
* @return True if sql types are required, otherwise false
* @since 1.2.0
*/
public boolean needsReturningSqlTypes();

/**
* TODO: documentation.
*
* @param ps TODO: documentation
* @param returningSqlTypes TODO: documentation
* @return The prepared statement
* @throws SQLException When preparing the statement fails
* @since 1.2.0
*/
public PreparedStatement prepare(PreparedStatement ps, int[] returningSqlTypes) throws SQLException;

/**
* TODO: documentation.
*
* @param ps TODO: documentation
* @return The result set for the returning clause
* @throws SQLException When extracting from the statement fails
* @since 1.2.0
*/
public ResultSet extractReturningResult(PreparedStatement ps) throws SQLException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ public Query getQuery() {
protected Query getQuery(Map<DbmsModificationState, String> includedModificationStates) {
Query query;

// TODO: Oracle requires everything except the sequence to be wrapped in a derived table
// see https://github.com/Blazebit/blaze-persistence/issues/306

// We use this to make these features only available to Hibernate as it is the only provider that supports sql replace yet
if (statementType == DbmsStatementType.INSERT
|| (hasLimit() || mainQuery.cteManager.hasCtes() || returningAttributeBindingMap.size() > 0)) {
Expand Down
Loading

0 comments on commit d90e895

Please sign in to comment.