diff --git a/.rultor.yml b/.rultor.yml
index dc5f647..e8f99d1 100644
--- a/.rultor.yml
+++ b/.rultor.yml
@@ -31,7 +31,7 @@ merge:
sudo sh -c 'echo "host all all localhost trust" > /etc/postgresql/9.3/main/pg_hba.conf'
sudo sh -c 'echo "local all all trust" >> /etc/postgresql/9.3/main/pg_hba.conf'
sudo service postgresql start
- sleep 30
+ sleep 30s
psql -c 'create database nativejson;' -U postgres
mvn install -Pci -B --settings ../settings.xml
@@ -40,13 +40,7 @@ env:
release:
script: |-
- sudo apt-get update -y
- sudo apt-get install -y postgresql-9.3
- sudo sh -c 'echo "host all all localhost trust" > /etc/postgresql/9.3/main/pg_hba.conf'
- sudo sh -c 'echo "local all all trust" >> /etc/postgresql/9.3/main/pg_hba.conf'
- sudo service postgresql start
- sleep 30
- psql -c 'create database nativejson;' -U postgres
+ ./initialize_postgres.sh
mvn versions:set "-DnewVersion=${tag}"
git commit -am "${tag}"
mvn deploy -Pci -B -Prelease --settings ../settings.xml -Dgpg.homedir=..
diff --git a/initialize_postgres.sh b/initialize_postgres.sh
new file mode 100755
index 0000000..cf7a34b
--- /dev/null
+++ b/initialize_postgres.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Copyright (C) 2016 Marvin Herman Froeder (marvin@marvinformatics.com)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# install postgresql, wait for it to start and then create test database
+
+set -x
+
+sudo sh -c 'echo "host all all localhost trust" > /etc/postgresql/9.3/main/pg_hba.conf'
+sudo sh -c 'echo "local all all trust" >> /etc/postgresql/9.3/main/pg_hba.conf'
+sudo rm /usr/bin/psql
+sudo ln -s /usr/lib/postgresql/9.3/bin/psql /usr/bin/psql
+sudo service postgresql start
+sleep 30s
+sudo service postgresql status
+psql -c 'create database nativejson;' -U postgres
diff --git a/pom.xml b/pom.xml
index a89e104..4478dbd 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,14 +58,14 @@
org.hibernate
hibernate-core
- 4.2.21.Final
+ 5.2.16.Final
provided
org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
- 1.0.1.Final
+ hibernate-jpa-2.1-api
+ 1.0.0.Final
provided
@@ -80,6 +80,12 @@
querydsl-jpa
${querydsl.version}
provided
+
+
+ org.hibernate
+ hibernate-core
+
+
diff --git a/src/main/java/com/marvinformatics/hibernate/json/JsonListUserType.java b/src/main/java/com/marvinformatics/hibernate/json/JsonListUserType.java
index fb6fd9a..acc5662 100644
--- a/src/main/java/com/marvinformatics/hibernate/json/JsonListUserType.java
+++ b/src/main/java/com/marvinformatics/hibernate/json/JsonListUserType.java
@@ -15,19 +15,18 @@
*/
package com.marvinformatics.hibernate.json;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.hibernate.HibernateException;
import org.hibernate.collection.internal.PersistentList;
import org.hibernate.collection.spi.PersistentCollection;
-import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.usertype.UserCollectionType;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
/**
* @author Marvin H Froeder
@@ -40,9 +39,9 @@ public JavaType createJavaType(ObjectMapper mapper) {
}
@Override
- public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister)
- throws HibernateException {
- return new PersistentList(session);
+ public PersistentCollection instantiate(SharedSessionContractImplementor sharedSessionContractImplementor,
+ CollectionPersister collectionPersister) throws HibernateException {
+ return new PersistentList(sharedSessionContractImplementor);
}
private PersistentList cast(Object collection) {
@@ -50,8 +49,9 @@ private PersistentList cast(Object collection) {
}
@Override
- public PersistentCollection wrap(SessionImplementor session, Object collection) {
- return new PersistentList(session, (List>) collection);
+ public PersistentCollection wrap(SharedSessionContractImplementor sharedSessionContractImplementor,
+ Object collection) {
+ return new PersistentList(sharedSessionContractImplementor, (List>) collection);
}
@Override
@@ -70,8 +70,13 @@ public Object indexOf(Object collection, Object entity) {
}
@Override
- public Object replaceElements(Object original, Object target, CollectionPersister persister, Object owner,
- @SuppressWarnings("rawtypes") Map copyCache, SessionImplementor session) throws HibernateException {
+ public Object replaceElements(
+ Object original,
+ Object target,
+ CollectionPersister persister,
+ Object owner,
+ @SuppressWarnings("rawtypes") Map copyCache,
+ SharedSessionContractImplementor session) throws HibernateException {
PersistentList originalList = cast(original);
PersistentList targetList = cast(target);
diff --git a/src/main/java/com/marvinformatics/hibernate/json/JsonSetUserType.java b/src/main/java/com/marvinformatics/hibernate/json/JsonSetUserType.java
index deaf5e2..d912c0c 100644
--- a/src/main/java/com/marvinformatics/hibernate/json/JsonSetUserType.java
+++ b/src/main/java/com/marvinformatics/hibernate/json/JsonSetUserType.java
@@ -15,19 +15,21 @@
*/
package com.marvinformatics.hibernate.json;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.hibernate.HibernateException;
import org.hibernate.collection.internal.PersistentSet;
import org.hibernate.collection.spi.PersistentCollection;
-import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.usertype.UserCollectionType;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
public class JsonSetUserType extends JsonUserType implements UserCollectionType {
+
public JsonSetUserType() {
}
@@ -35,16 +37,20 @@ public JavaType createJavaType(ObjectMapper mapper) {
return mapper.getTypeFactory().constructCollectionType(Set.class, this.returnedClass());
}
- public PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister) throws HibernateException {
- return new PersistentSet(session);
+ @Override
+ public PersistentCollection instantiate(SharedSessionContractImplementor sharedSessionContractImplementor,
+ CollectionPersister collectionPersister) throws HibernateException {
+ return new PersistentSet(sharedSessionContractImplementor);
}
private PersistentSet cast(Object collection) {
return (PersistentSet) collection;
}
- public PersistentCollection wrap(SessionImplementor session, Object collection) {
- return new PersistentSet(session, (Set>) collection);
+ @Override
+ public PersistentCollection wrap(SharedSessionContractImplementor sharedSessionContractImplementor,
+ Object collection) {
+ return new PersistentSet(sharedSessionContractImplementor, (Set>) collection);
}
public Iterator> getElementsIterator(Object collection) {
@@ -59,12 +65,14 @@ public Object indexOf(Object collection, Object entity) {
throw new UnsupportedOperationException();
}
- public Object replaceElements(Object original,
+ @Override
+ public Object replaceElements(
+ Object original,
Object target,
CollectionPersister persister,
Object owner,
Map copyCache,
- SessionImplementor session) throws HibernateException {
+ SharedSessionContractImplementor session) throws HibernateException {
PersistentSet originalSet = this.cast(original);
PersistentSet targetSet = this.cast(target);
targetSet.clear();
diff --git a/src/main/java/com/marvinformatics/hibernate/json/JsonUserType.java b/src/main/java/com/marvinformatics/hibernate/json/JsonUserType.java
index c050420..63a9dba 100644
--- a/src/main/java/com/marvinformatics/hibernate/json/JsonUserType.java
+++ b/src/main/java/com/marvinformatics/hibernate/json/JsonUserType.java
@@ -15,6 +15,16 @@
*/
package com.marvinformatics.hibernate.json;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.SimpleType;
+import org.hibernate.HibernateException;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.hibernate.usertype.DynamicParameterizedType;
+import org.hibernate.usertype.UserType;
+import org.postgresql.util.PGobject;
+
import java.io.IOException;
import java.io.Serializable;
import java.sql.PreparedStatement;
@@ -23,17 +33,6 @@
import java.sql.Types;
import java.util.Properties;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.spi.SessionImplementor;
-import org.hibernate.usertype.DynamicParameterizedType;
-import org.hibernate.usertype.UserType;
-import org.postgresql.util.PGobject;
-
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.SimpleType;
-
/**
* Define a Jackson Serializer/Deserializer use to persist
*
@@ -69,7 +68,7 @@ public boolean isMutable() {
}
@Override
- public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
+ public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException {
PGobject dataObject = new PGobject();
dataObject.setType("json");
@@ -80,7 +79,7 @@ public void nullSafeSet(PreparedStatement st, Object value, int index, SessionIm
}
@Override
- public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
+ public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException {
Object result = rs.getObject(names[0]);
if (result instanceof PGobject)
return convertJsonToObject(((PGobject) result).getValue());