Skip to content

Commit

Permalink
Upgrade Hibernate to 5.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Jul 21, 2016
1 parent a926f44 commit 6bda502
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
2 changes: 1 addition & 1 deletion libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ext {
jposVersion = '2.0.7-SNAPSHOT'
slf4jVersion = '1.7.21'
logbackVersion = '1.1.7'
hibernateVersion = '5.1.0.Final'
hibernateVersion = '5.2.1.Final'
geronimoVersion = '1.1.1'
jettyVersion = '9.2.17.v20160517'
servletApiVersion = '3.1.0'
Expand Down
28 changes: 26 additions & 2 deletions modules/dbsupport/src/main/java/org/jpos/ee/usertype/JsonType.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;

import java.io.IOException;
Expand Down Expand Up @@ -38,8 +39,19 @@ public int hashCode(Object x) throws HibernateException {
return x.hashCode();
}

/**
* Retrieve an instance of the mapped class from a JDBC resultset. Implementors
* should handle possibility of null values.
*
* @param rs a JDBC result set
* @param names the column names
* @param session
* @param owner the containing entity @return Object
* @throws HibernateException
* @throws SQLException
*/
@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 {
String json = rs.getString(names[0]);
if (rs.wasNull())
return null;
Expand All @@ -50,8 +62,20 @@ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor sessi
}
}

/**
* Write an instance of the mapped class to a prepared statement. Implementors
* should handle possibility of null values. A multi-column type should be written
* to parameters starting from <tt>index</tt>.
*
* @param st a JDBC prepared statement
* @param value the object to write
* @param index statement parameter index
* @param session
* @throws HibernateException
* @throws SQLException
*/
@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 {
if (value==null) {
st.setNull(index, Types.VARCHAR);
} else {
Expand Down
28 changes: 26 additions & 2 deletions modules/dbsupport/src/main/java/org/jpos/ee/usertype/TagsType.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;

import java.io.Serializable;
Expand Down Expand Up @@ -53,16 +54,39 @@ public int hashCode(Object o) throws HibernateException {
return o.hashCode();
}

/**
* Retrieve an instance of the mapped class from a JDBC resultset. Implementors
* should handle possibility of null values.
*
* @param rs a JDBC result set
* @param names the column names
* @param session
* @param owner the containing entity @return Object
* @throws HibernateException
* @throws SQLException
*/
@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 {
String tags = rs.getString(names[0]);
if (rs.wasNull())
return null;
return new Tags(tags);
}

/**
* Write an instance of the mapped class to a prepared statement. Implementors
* should handle possibility of null values. A multi-column type should be written
* to parameters starting from <tt>index</tt>.
*
* @param st a JDBC prepared statement
* @param value the object to write
* @param index statement parameter index
* @param session
* @throws HibernateException
* @throws SQLException
*/
@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 {
if (value==null) {
st.setNull(index, Types.VARCHAR);
} else {
Expand Down
1 change: 0 additions & 1 deletion modules/minigl/src/main/java/org/jpos/gl/GLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,6 @@ private void invalidateCheckpoints (GLTransaction txn)
Checkpoint cp = (Checkpoint) iter.next();
session.delete (cp);
}
session.flush();
}
private BigDecimal applyEntries (BigDecimal balance, List entries)
throws GLException
Expand Down
12 changes: 6 additions & 6 deletions modules/minigl/src/main/java/org/jpos/gl/tools/Import.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ public static void usage () {
}

private void createSchema () throws HibernateException, DocumentException {
new DB().createSchema(null, true);
DB db = new DB();
db.open();
db.beginTransaction();
db.createSchema(null, true);
db.commit();
db.close();
}

private void createCharts (Session sess, Iterator iter)
Expand All @@ -82,7 +87,6 @@ private void createCharts (Session sess, Iterator iter)
sess.flush ();
}
txn.commit();
sess.flush ();
}
private void createCurrencies (Session sess, Iterator iter)
throws SQLException, HibernateException, ParseException
Expand All @@ -94,7 +98,6 @@ private void createCurrencies (Session sess, Iterator iter)
sess.save (currency);
}
txn.commit();
sess.flush ();
}
private void createUsers (Session sess, Iterator iter)
throws SQLException, HibernateException, ParseException
Expand All @@ -114,7 +117,6 @@ private void createUsers (Session sess, Iterator iter)
sess.save (user);
}
txn.commit();
sess.flush ();
}
private void createJournals (Session sess, Iterator iter)
throws SQLException, HibernateException, ParseException
Expand All @@ -140,7 +142,6 @@ private void createJournals (Session sess, Iterator iter)
);
}
txn.commit();
sess.flush ();
}
private void processChartChildren
(Session sess, CompositeAccount parent, Iterator iter)
Expand Down Expand Up @@ -196,7 +197,6 @@ private void createTransactions (Session sess, Iterator iter)
);
txn.commit ();
}
sess.flush ();
}
private void createEntries (
Session sess, GLTransaction glt, Iterator iter)
Expand Down

0 comments on commit 6bda502

Please sign in to comment.