HHH-5941 : remove deprecated set(), nullSafeSet(), get(), nullSafeGet() methods and add SessionImplementer argument to UserType.nullSafeGet()/nullSafeSet()
This commit is contained in:
parent
89eabb920d
commit
7243d04541
|
@ -48,38 +48,10 @@ public abstract class AbstractSingleColumnStandardBasicType<T>
|
||||||
super( sqlTypeDescriptor, javaTypeDescriptor );
|
super( sqlTypeDescriptor, javaTypeDescriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WrapperOptions NO_OPTIONS = new WrapperOptions() {
|
|
||||||
public boolean useStreamForLobBinding() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LobCreator getLobCreator() {
|
|
||||||
return NonContextualLobCreator.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SqlTypeDescriptor resolveSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
|
|
||||||
return sqlTypeDescriptor;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public final int sqlType() {
|
public final int sqlType() {
|
||||||
return getSqlTypeDescriptor().getSqlType();
|
return getSqlTypeDescriptor().getSqlType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public T nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
|
|
||||||
return nullSafeGet( rs, name, NO_OPTIONS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
|
|
||||||
return nullSafeGet( rs, name );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -89,19 +61,4 @@ public abstract class AbstractSingleColumnStandardBasicType<T>
|
||||||
nullSafeSet( st, value, index, session );
|
nullSafeSet( st, value, index, session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void nullSafeSet(PreparedStatement st, T value, int index) throws HibernateException, SQLException {
|
|
||||||
nullSafeSet( st, value, index, NO_OPTIONS );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public void set(PreparedStatement st, T value, int index) throws HibernateException, SQLException {
|
|
||||||
nullSafeSet( st, value, index );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -106,7 +106,7 @@ public class CustomType extends AbstractType implements IdentifierType, Discrimi
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return userType.nullSafeGet(rs, names, owner);
|
return userType.nullSafeGet(rs, names, session, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String columnName, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String columnName, SessionImplementor session, Object owner)
|
||||||
|
@ -137,13 +137,13 @@ public class CustomType extends AbstractType implements IdentifierType, Discrimi
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
|
public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
if ( settable[0] ) {
|
if ( settable[0] ) {
|
||||||
userType.nullSafeSet( st, value, index );
|
userType.nullSafeSet( st, value, index, session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
userType.nullSafeSet( st, value, index );
|
userType.nullSafeSet( st, value, index, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "UnusedDeclaration" })
|
@SuppressWarnings({ "UnusedDeclaration" })
|
||||||
|
|
|
@ -34,6 +34,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.EnhancedUserType;
|
import org.hibernate.usertype.EnhancedUserType;
|
||||||
import org.hibernate.usertype.ParameterizedType;
|
import org.hibernate.usertype.ParameterizedType;
|
||||||
import org.hibernate.util.ReflectHelper;
|
import org.hibernate.util.ReflectHelper;
|
||||||
|
@ -97,7 +98,7 @@ public class EnumType implements EnhancedUserType, ParameterizedType, Serializab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
Object object = rs.getObject( names[0] );
|
Object object = rs.getObject( names[0] );
|
||||||
if ( rs.wasNull() ) {
|
if ( rs.wasNull() ) {
|
||||||
if ( IS_VALUE_TRACING_ENABLED ) {
|
if ( IS_VALUE_TRACING_ENABLED ) {
|
||||||
|
@ -130,7 +131,7 @@ public class EnumType implements EnhancedUserType, ParameterizedType, Serializab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
if ( IS_VALUE_TRACING_ENABLED ) {
|
if ( IS_VALUE_TRACING_ENABLED ) {
|
||||||
log().debug( "Binding null to parameter: {}", index );
|
log().debug( "Binding null to parameter: {}", index );
|
||||||
|
|
|
@ -46,12 +46,6 @@ public interface SingleColumnType<T> extends Type {
|
||||||
|
|
||||||
public T fromStringValue(String xml) throws HibernateException;
|
public T fromStringValue(String xml) throws HibernateException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #nullSafeGet(ResultSet, String, SessionImplementor)} instead
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "JavaDoc" })
|
|
||||||
public T nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a column value from a result set by name.
|
* Get a column value from a result set by name.
|
||||||
*
|
*
|
||||||
|
@ -66,14 +60,6 @@ public interface SingleColumnType<T> extends Type {
|
||||||
*/
|
*/
|
||||||
public T nullSafeGet(ResultSet rs, String name, SessionImplementor session) throws HibernateException, SQLException;
|
public T nullSafeGet(ResultSet rs, String name, SessionImplementor session) throws HibernateException, SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT USER THIS FORM!
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link #get(ResultSet, String, SessionImplementor)} instead.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "JavaDoc" })
|
|
||||||
public Object get(ResultSet rs, String name) throws HibernateException, SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a column value from a result set, without worrying about the possibility of null values.
|
* Get a column value from a result set, without worrying about the possibility of null values.
|
||||||
*
|
*
|
||||||
|
@ -88,22 +74,6 @@ public interface SingleColumnType<T> extends Type {
|
||||||
*/
|
*/
|
||||||
public Object get(ResultSet rs, String name, SessionImplementor session) throws HibernateException, SQLException;
|
public Object get(ResultSet rs, String name, SessionImplementor session) throws HibernateException, SQLException;
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT USE THIS FORM!
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link #nullSafeSet(PreparedStatement, Object, int, SessionImplementor)} instead.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "JavaDoc" })
|
|
||||||
public void nullSafeSet(PreparedStatement st, T value, int index) throws HibernateException, SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DO NOT USE THIS FORM!
|
|
||||||
*
|
|
||||||
* @deprecated Use {@link #set(PreparedStatement, Object, int, SessionImplementor)} instead.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({ "JavaDoc" })
|
|
||||||
public void set(PreparedStatement st, T value, int index) throws HibernateException, SQLException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a parameter value without worrying about the possibility of null
|
* Set a parameter value without worrying about the possibility of null
|
||||||
* values. Called from {@link #nullSafeSet} after nullness checks have
|
* values. Called from {@link #nullSafeSet} after nullness checks have
|
||||||
|
|
|
@ -33,6 +33,7 @@ import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +60,7 @@ public class StringClobType implements UserType, Serializable {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
Reader reader = rs.getCharacterStream( names[0] );
|
Reader reader = rs.getCharacterStream( names[0] );
|
||||||
if ( reader == null ) return null;
|
if ( reader == null ) return null;
|
||||||
StringBuilder result = new StringBuilder( 4096 );
|
StringBuilder result = new StringBuilder( 4096 );
|
||||||
|
@ -75,7 +76,7 @@ public class StringClobType implements UserType, Serializable {
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
String string = (String) value;
|
String string = (String) value;
|
||||||
StringReader reader = new StringReader( string );
|
StringReader reader = new StringReader( string );
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface should be implemented by user-defined "types".
|
* This interface should be implemented by user-defined "types".
|
||||||
|
@ -100,27 +101,30 @@ public interface UserType {
|
||||||
* Retrieve an instance of the mapped class from a JDBC resultset. Implementors
|
* Retrieve an instance of the mapped class from a JDBC resultset. Implementors
|
||||||
* should handle possibility of null values.
|
* should handle possibility of null values.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param rs a JDBC result set
|
* @param rs a JDBC result set
|
||||||
* @param names the column names
|
* @param names the column names
|
||||||
* @param owner the containing entity
|
* @param session
|
||||||
* @return Object
|
*@param owner the containing entity @return Object
|
||||||
* @throws HibernateException
|
* @throws HibernateException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException;
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write an instance of the mapped class to a prepared statement. Implementors
|
* 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
|
* should handle possibility of null values. A multi-column type should be written
|
||||||
* to parameters starting from <tt>index</tt>.
|
* to parameters starting from <tt>index</tt>.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* @param st a JDBC prepared statement
|
* @param st a JDBC prepared statement
|
||||||
* @param value the object to write
|
* @param value the object to write
|
||||||
* @param index statement parameter index
|
* @param index statement parameter index
|
||||||
|
* @param session
|
||||||
* @throws HibernateException
|
* @throws HibernateException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
*/
|
*/
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException;
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a deep copy of the persistent state, stopping at entities and at
|
* Return a deep copy of the persistent state, stopping at entities and at
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.sql.Types;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.ParameterizedType;
|
import org.hibernate.usertype.ParameterizedType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ public class CasterStringType implements UserType, ParameterizedType {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
String result = rs.getString( names[0] );
|
String result = rs.getString( names[0] );
|
||||||
if ( rs.wasNull() ) return null;
|
if ( rs.wasNull() ) return null;
|
||||||
if ( parameters.getProperty( CAST ).equals( "lower" ) ) {
|
if ( parameters.getProperty( CAST ).equals( "lower" ) ) {
|
||||||
|
@ -48,7 +49,7 @@ public class CasterStringType implements UserType, ParameterizedType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
st.setNull( index, sqlTypes()[0] );
|
st.setNull( index, sqlTypes()[0] );
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class MonetaryAmountUserType implements CompositeUserType {
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
|
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0], session);
|
||||||
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
|
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||||
if ( amt == null ) return null;
|
if ( amt == null ) return null;
|
||||||
return new MonetaryAmount( amt, cur );
|
return new MonetaryAmount( amt, cur );
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,8 @@ public class MonetaryAmountUserType implements CompositeUserType {
|
||||||
MonetaryAmount ma = (MonetaryAmount) value;
|
MonetaryAmount ma = (MonetaryAmount) value;
|
||||||
BigDecimal amt = ma == null ? null : ma.getAmount();
|
BigDecimal amt = ma == null ? null : ma.getAmount();
|
||||||
Currency cur = ma == null ? null : ma.getCurrency();
|
Currency cur = ma == null ? null : ma.getCurrency();
|
||||||
Hibernate.BIG_DECIMAL.nullSafeSet( st, amt, index );
|
Hibernate.BIG_DECIMAL.nullSafeSet( st, amt, index, session );
|
||||||
Hibernate.CURRENCY.nullSafeSet( st, cur, index + 1 );
|
Hibernate.CURRENCY.nullSafeSet( st, cur, index + 1, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object value) throws HibernateException {
|
public Object deepCopy(Object value) throws HibernateException {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +55,7 @@ public class PhoneNumberType implements UserType {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
String result = rs.getString( names[0] );
|
String result = rs.getString( names[0] );
|
||||||
if ( rs.wasNull() ) return null;
|
if ( rs.wasNull() ) return null;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public class PhoneNumberType implements UserType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
st.setNull( index, sqlTypes()[0] );
|
st.setNull( index, sqlTypes()[0] );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.sql.SQLException;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
|
||||||
|
@ -32,13 +33,13 @@ public class StateType implements UserType {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
int result = rs.getInt( names[0] );
|
int result = rs.getInt( names[0] );
|
||||||
if ( rs.wasNull() ) return null;
|
if ( rs.wasNull() ) return null;
|
||||||
return State.values()[result];
|
return State.values()[result];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
st.setNull( index, Types.INTEGER );
|
st.setNull( index, Types.INTEGER );
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,10 @@ public class MyOidType implements CompositeUserType {
|
||||||
public Object nullSafeGet(
|
public Object nullSafeGet(
|
||||||
ResultSet aResultSet, String[] names, SessionImplementor aSessionImplementor, Object aObject
|
ResultSet aResultSet, String[] names, SessionImplementor aSessionImplementor, Object aObject
|
||||||
) throws HibernateException, SQLException {
|
) throws HibernateException, SQLException {
|
||||||
Integer highval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[0] );
|
Integer highval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[0], aSessionImplementor );
|
||||||
Integer midval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[1] );
|
Integer midval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[1], aSessionImplementor );
|
||||||
Integer lowval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[2] );
|
Integer lowval = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[2], aSessionImplementor );
|
||||||
Integer other = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[3] );
|
Integer other = (Integer) Hibernate.INTEGER.nullSafeGet( aResultSet, names[3], aSessionImplementor );
|
||||||
|
|
||||||
return new MyOid( highval, midval, lowval, other );
|
return new MyOid( highval, midval, lowval, other );
|
||||||
}
|
}
|
||||||
|
@ -113,10 +113,10 @@ public class MyOidType implements CompositeUserType {
|
||||||
c = (MyOid) value;
|
c = (MyOid) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getHigh(), index );
|
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getHigh(), index, aSessionImplementor );
|
||||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getMiddle(), index + 1 );
|
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getMiddle(), index + 1, aSessionImplementor );
|
||||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getLow(), index + 2 );
|
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getLow(), index + 2, aSessionImplementor );
|
||||||
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getOther(), index + 3 );
|
Hibernate.INTEGER.nullSafeSet( aPreparedStatement, c.getOther(), index + 3, aSessionImplementor );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object aObject) throws HibernateException {
|
public Object deepCopy(Object aObject) throws HibernateException {
|
||||||
|
|
|
@ -62,8 +62,8 @@ public class MonetoryAmountUserType implements CompositeUserType {
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
|
BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0], session );
|
||||||
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
|
Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||||
if (amt==null) return null;
|
if (amt==null) return null;
|
||||||
return new MonetoryAmount(amt, cur);
|
return new MonetoryAmount(amt, cur);
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ public class MonetoryAmountUserType implements CompositeUserType {
|
||||||
MonetoryAmount ma = (MonetoryAmount) value;
|
MonetoryAmount ma = (MonetoryAmount) value;
|
||||||
BigDecimal amt = ma == null ? null : ma.getAmount();
|
BigDecimal amt = ma == null ? null : ma.getAmount();
|
||||||
Currency cur = ma == null ? null : ma.getCurrency();
|
Currency cur = ma == null ? null : ma.getCurrency();
|
||||||
Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index);
|
Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index, session);
|
||||||
Hibernate.CURRENCY.nullSafeSet(st, cur, index+1);
|
Hibernate.CURRENCY.nullSafeSet(st, cur, index+1, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object value) throws HibernateException {
|
public Object deepCopy(Object value) throws HibernateException {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.hibernate.test.hql;
|
package org.hibernate.test.hql;
|
||||||
|
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.type.IntegerType;
|
import org.hibernate.type.IntegerType;
|
||||||
import org.hibernate.usertype.EnhancedUserType;
|
import org.hibernate.usertype.EnhancedUserType;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -46,14 +47,14 @@ public class ClassificationType implements EnhancedUserType {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
Integer ordinal = ( Integer ) IntegerType.INSTANCE.nullSafeGet( rs, names[0] );
|
Integer ordinal = ( Integer ) IntegerType.INSTANCE.nullSafeGet( rs, names[0], session );
|
||||||
return Classification.valueOf( ordinal );
|
return Classification.valueOf( ordinal );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
Integer ordinal = value == null ? null : new Integer( ( ( Classification ) value ).ordinal() );
|
Integer ordinal = value == null ? null : new Integer( ( ( Classification ) value ).ordinal() );
|
||||||
Hibernate.INTEGER.nullSafeSet( st, ordinal, index );
|
Hibernate.INTEGER.nullSafeSet( st, ordinal, index, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object value) throws HibernateException {
|
public Object deepCopy(Object value) throws HibernateException {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Arrays;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,17 +19,17 @@ public class CustomBlobType implements UserType {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public Object nullSafeGet(ResultSet rs, String names[], Object owner) throws SQLException {
|
public Object nullSafeGet(ResultSet rs, String names[], SessionImplementor session, Object owner) throws SQLException {
|
||||||
// cast just to make sure...
|
// cast just to make sure...
|
||||||
return ( byte[] ) Hibernate.BINARY.nullSafeGet( rs, names[0] );
|
return ( byte[] ) Hibernate.BINARY.nullSafeGet( rs, names[0], session );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void nullSafeSet(PreparedStatement ps, Object value, int index) throws SQLException, HibernateException {
|
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
|
||||||
// cast just to make sure...
|
// cast just to make sure...
|
||||||
Hibernate.BINARY.nullSafeSet( ps, ( byte[] ) value, index );
|
Hibernate.BINARY.nullSafeSet( ps, ( byte[] ) value, index, session );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,12 +32,12 @@ public class RowIdType implements UserType {
|
||||||
return x.hashCode();
|
return x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
return rs.getObject( names[0] );
|
return rs.getObject( names[0] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index)
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.sql.Types;
|
||||||
import java.util.Currency;
|
import java.util.Currency;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +41,7 @@ public class MonetaryAmountUserType
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet resultSet,
|
public Object nullSafeGet(ResultSet resultSet,
|
||||||
String[] names,
|
String[] names,
|
||||||
Object owner)
|
SessionImplementor session, Object owner)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
|
|
||||||
BigDecimal value = resultSet.getBigDecimal(names[0]);
|
BigDecimal value = resultSet.getBigDecimal(names[0]);
|
||||||
|
@ -53,7 +54,7 @@ public class MonetaryAmountUserType
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement statement,
|
public void nullSafeSet(PreparedStatement statement,
|
||||||
Object value,
|
Object value,
|
||||||
int index)
|
int index, SessionImplementor session)
|
||||||
throws HibernateException, SQLException {
|
throws HibernateException, SQLException {
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.usertype.ParameterizedType;
|
import org.hibernate.usertype.ParameterizedType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
|
@ -34,12 +35,12 @@ public class DefaultValueIntegerType implements UserType, ParameterizedType, Ser
|
||||||
return x.equals(y);
|
return x.equals(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
Number result = (Number) rs.getObject(names[0]);
|
Number result = (Number) rs.getObject(names[0]);
|
||||||
return result==null ? defaultValue : new Integer(result.intValue());
|
return result==null ? defaultValue : new Integer(result.intValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if (value == null || defaultValue.equals(value) ) {
|
if (value == null || defaultValue.equals(value) ) {
|
||||||
LoggerFactory.getLogger( getClass() ).trace("binding null to parameter: " + index);
|
LoggerFactory.getLogger( getClass() ).trace("binding null to parameter: " + index);
|
||||||
st.setNull(index, Types.INTEGER);
|
st.setNull(index, Types.INTEGER);
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
package org.hibernate.type;
|
package org.hibernate.type;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.Socket;
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -35,7 +34,6 @@ import junit.framework.TestCase;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.UrlTypeDescriptor;
|
|
||||||
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
import org.hibernate.type.descriptor.sql.VarcharTypeDescriptor;
|
||||||
import org.hibernate.usertype.CompositeUserType;
|
import org.hibernate.usertype.CompositeUserType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
@ -132,11 +130,11 @@ public class BasicTypeRegistryTest extends TestCase {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object value) throws HibernateException {
|
public Object deepCopy(Object value) throws HibernateException {
|
||||||
|
|
|
@ -29,9 +29,11 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.envers.RevisionType;
|
import org.hibernate.envers.RevisionType;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.type.IntegerType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,23 +51,20 @@ public class RevisionTypeType implements UserType {
|
||||||
return RevisionType.class;
|
return RevisionType.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RevisionType nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException {
|
public RevisionType nullSafeGet(ResultSet resultSet, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
byte representation = (byte) resultSet.getInt(names[0]);
|
Integer representationInt = IntegerType.INSTANCE.nullSafeGet( resultSet, names[0], session );
|
||||||
RevisionType result = null;
|
return representationInt == null ?
|
||||||
|
null :
|
||||||
if (!resultSet.wasNull()) {
|
RevisionType.fromRepresentation( representationInt.byteValue() );
|
||||||
result = RevisionType.fromRepresentation(representation);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if (null == value) {
|
IntegerType.INSTANCE.nullSafeSet(
|
||||||
preparedStatement.setNull(index, Types.TINYINT);
|
preparedStatement,
|
||||||
} else {
|
( value == null ? null : ((RevisionType) value).getRepresentation().intValue() ),
|
||||||
preparedStatement.setInt(index, ((RevisionType) value).getRepresentation());
|
index,
|
||||||
}
|
session
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object deepCopy(Object value) throws HibernateException{
|
public Object deepCopy(Object value) throws HibernateException{
|
||||||
|
|
|
@ -30,8 +30,8 @@ import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
import org.hibernate.type.StringType;
|
import org.hibernate.type.StringType;
|
||||||
import org.hibernate.usertype.ParameterizedType;
|
import org.hibernate.usertype.ParameterizedType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
@ -54,11 +54,11 @@ public class ParametrizedTestUserType implements UserType, ParameterizedType {
|
||||||
return String.class;
|
return String.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
return StringType.INSTANCE.nullSafeGet( rs, names[0] );
|
return StringType.INSTANCE.nullSafeGet( rs, names[0], session );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
String v = (String) value;
|
String v = (String) value;
|
||||||
if (!v.startsWith(param1)) {
|
if (!v.startsWith(param1)) {
|
||||||
|
@ -67,10 +67,10 @@ public class ParametrizedTestUserType implements UserType, ParameterizedType {
|
||||||
if (!v.endsWith(param2)) {
|
if (!v.endsWith(param2)) {
|
||||||
v = v + param2;
|
v = v + param2;
|
||||||
}
|
}
|
||||||
StringType.INSTANCE.nullSafeSet(st, v, index);
|
StringType.INSTANCE.nullSafeSet(st, v, index, session);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
StringType.INSTANCE.nullSafeSet( st, null, index );
|
StringType.INSTANCE.nullSafeSet( st, null, index, session );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.engine.SessionImplementor;
|
||||||
|
import org.hibernate.type.StringType;
|
||||||
import org.hibernate.usertype.UserType;
|
import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +62,7 @@ public class CustomEnumUserType implements UserType {
|
||||||
return (x == null) ? 0 : x.hashCode();
|
return (x == null) ? 0 : x.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
|
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
|
||||||
String name = rs.getString(names[0]);
|
String name = rs.getString(names[0]);
|
||||||
if (rs.wasNull()) {
|
if (rs.wasNull()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -68,7 +70,7 @@ public class CustomEnumUserType implements UserType {
|
||||||
return CustomEnum.fromYesNo(name);
|
return CustomEnum.fromYesNo(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
|
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
|
||||||
CustomEnum val = (CustomEnum) value;
|
CustomEnum val = (CustomEnum) value;
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
st.setNull(index, Types.VARCHAR);
|
st.setNull(index, Types.VARCHAR);
|
||||||
|
|
Loading…
Reference in New Issue