remove use of SharedSessionContractImplementor in UserType

it was arguably a layer-breaker
This commit is contained in:
Gavin King 2024-12-14 17:02:19 +01:00
parent c5c9f1184d
commit 86a43ca9dd
39 changed files with 147 additions and 130 deletions

View File

@ -14,8 +14,8 @@ import org.hibernate.sql.model.PreparableMutationOperation;
import org.hibernate.sql.model.TableMapping; import org.hibernate.sql.model.TableMapping;
/** /**
* {@link PreparedStatementGroup} implementation for cases where we * {@link org.hibernate.engine.jdbc.mutation.group.PreparedStatementGroup}
* have just a single operation * implementation for cases where we have just a single operation
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -18,9 +18,9 @@ import org.hibernate.HibernateException;
import org.hibernate.annotations.Nationalized; import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.EnumJavaType; import org.hibernate.type.descriptor.java.EnumJavaType;
import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType; import org.hibernate.type.descriptor.jdbc.JdbcType;
@ -219,10 +219,10 @@ public class EnumType<T extends Enum<T>>
} }
@Override @Override
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public T nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
verifyConfigured(); verifyConfigured();
return jdbcType.getExtractor( enumJavaType ).extract( rs, position, session ); return jdbcType.getExtractor( enumJavaType ).extract( rs, position, options );
} }
private void verifyConfigured() { private void verifyConfigured() {
@ -232,10 +232,10 @@ public class EnumType<T extends Enum<T>>
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, T value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
verifyConfigured(); verifyConfigured();
jdbcType.getBinder( enumJavaType ).bind( st, value, index, session ); jdbcType.getBinder( enumJavaType ).bind( st, value, index, options );
} }
@Override @Override

View File

@ -24,7 +24,7 @@ import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
* Adapts UserType to the JdbcType contract * Adapts {@link UserType} to the {@link JdbcType} contract
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -11,9 +11,9 @@ import java.sql.SQLException;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.BasicJavaType; import org.hibernate.type.descriptor.java.BasicJavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType; import org.hibernate.type.descriptor.jdbc.JdbcType;
@ -80,15 +80,15 @@ public abstract class BaseUserTypeSupport<T> implements UserType<T> {
} }
@Override @Override
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) throws SQLException { public T nullSafeGet(ResultSet rs, int position, WrapperOptions options) throws SQLException {
ensureResolved(); ensureResolved();
return jdbcValueExtractor.extract( rs, position, session ); return jdbcValueExtractor.extract( rs, position, options );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) throws SQLException { public void nullSafeSet(PreparedStatement st, T value, int index, WrapperOptions options) throws SQLException {
ensureResolved(); ensureResolved();
jdbcValueBinder.bind( st, value, index, session ); jdbcValueBinder.bind( st, value, index, options );
} }
@Override @Override

View File

@ -10,7 +10,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.ValueExtractor;
@ -113,9 +113,9 @@ public class StaticUserTypeSupport<T> implements UserType<T> {
} }
@Override @Override
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public T nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
final Object extracted = jdbcValueExtractor.extract( rs, position, session ); final Object extracted = jdbcValueExtractor.extract( rs, position, options );
if ( valueConverter != null ) { if ( valueConverter != null ) {
return valueConverter.toDomainValue( extracted ); return valueConverter.toDomainValue( extracted );
@ -126,7 +126,7 @@ public class StaticUserTypeSupport<T> implements UserType<T> {
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, T value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
final Object valueToBind; final Object valueToBind;
if ( valueConverter != null ) { if ( valueConverter != null ) {
@ -136,7 +136,7 @@ public class StaticUserTypeSupport<T> implements UserType<T> {
valueToBind = value; valueToBind = value;
} }
jdbcValueBinder.bind( st, valueToBind, index, session ); jdbcValueBinder.bind( st, valueToBind, index, options );
} }
@Override @Override

View File

@ -15,6 +15,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.Size; import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
import org.hibernate.type.descriptor.jdbc.JdbcType; import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
@ -63,16 +64,14 @@ import org.hibernate.type.spi.TypeConfiguration;
* } * }
* *
* &#64;Override * &#64;Override
* public Period nullSafeGet(ResultSet rs, int position, * public Period nullSafeGet(ResultSet rs, int position, WrapperOptions options)
* SharedSessionContractImplementor session)
* throws SQLException { * throws SQLException {
* String string = rs.getString(position); * String string = rs.getString(position);
* return rs.wasNull() ? null : Period.parse(string); * return rs.wasNull() ? null : Period.parse(string);
* } * }
* *
* &#64;Override * &#64;Override
* public void nullSafeSet(PreparedStatement st, Period value, int index, * public void nullSafeSet(PreparedStatement st, Period value, int index, WrapperOptions options)
* SharedSessionContractImplementor session)
* throws SQLException { * throws SQLException {
* if ( value == null ) { * if ( value == null ) {
* st.setNull(index, VARCHAR); * st.setNull(index, VARCHAR);
@ -169,16 +168,14 @@ import org.hibernate.type.spi.TypeConfiguration;
* } * }
* *
* &#64;Override * &#64;Override
* public BitSet nullSafeGet(ResultSet rs, int position, * public BitSet nullSafeGet(ResultSet rs, int position, WrapperOptions options)
* SharedSessionContractImplementor session)
* throws SQLException { * throws SQLException {
* String string = rs.getString(position); * String string = rs.getString(position);
* return rs.wasNull()? null : parseBitSet(columnValue); * return rs.wasNull()? null : parseBitSet(columnValue);
* } * }
* *
* &#64;Override * &#64;Override
* public void nullSafeSet(PreparedStatement st, BitSet bitSet, int index, * public void nullSafeSet(PreparedStatement st, BitSet bitSet, int index, WrapperOptions options)
* SharedSessionContractImplementor session)
* throws SQLException { * throws SQLException {
* if (bitSet == null) { * if (bitSet == null) {
* st.setNull(index, VARCHAR); * st.setNull(index, VARCHAR);
@ -296,7 +293,7 @@ public interface UserType<J> {
* *
* @param owner since Hibernate 6, this is always null * @param owner since Hibernate 6, this is always null
* *
* @deprecated Implement {@link #nullSafeGet(ResultSet, int, SharedSessionContractImplementor)} * @deprecated Implement {@link #nullSafeGet(ResultSet, int, WrapperOptions)}
*/ */
@Deprecated(since = "7", forRemoval = true) @Deprecated(since = "7", forRemoval = true)
default J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, @Deprecated Object owner) default J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, @Deprecated Object owner)
@ -314,7 +311,7 @@ public interface UserType<J> {
* given {@code position} and with the * given {@code position} and with the
* {@linkplain #returnedClass returned class}. * {@linkplain #returnedClass returned class}.
*/ */
default J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) default J nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
J result = rs.getObject( position, returnedClass() ); J result = rs.getObject( position, returnedClass() );
return rs.wasNull() ? null : result; return rs.wasNull() ? null : result;
@ -330,9 +327,28 @@ public interface UserType<J> {
* {@link PreparedStatement#setObject(int, Object, int)} * {@link PreparedStatement#setObject(int, Object, int)}
* with the given {@code position} and {@code value} and * with the given {@code position} and {@code value} and
* with the {@linkplain #getSqlType SQL type}. * with the {@linkplain #getSqlType SQL type}.
*
* @deprecated Implement {@link #nullSafeSet(PreparedStatement, Object, int, WrapperOptions)}
*/ */
@Deprecated(since = "7", forRemoval = true)
default void nullSafeSet(PreparedStatement st, J value, int position, SharedSessionContractImplementor session) default void nullSafeSet(PreparedStatement st, J value, int position, SharedSessionContractImplementor session)
throws SQLException { throws SQLException {
nullSafeSet( st, value, position, (WrapperOptions) session );
}
/**
* Write an instance of the Java class mapped by this custom type
* to the given JDBC {@link PreparedStatement}. Implementors must
* handle null values of the Java class. A multi-column type should
* be written to parameters starting from {@code index}.
*
* @implNote The default implementation calls
* {@link PreparedStatement#setObject(int, Object, int)}
* with the given {@code position} and {@code value} and
* with the {@linkplain #getSqlType SQL type}.
*/
default void nullSafeSet(PreparedStatement st, J value, int position, WrapperOptions options)
throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( position, getSqlType() ); st.setNull( position, getSqlType() );
} }

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -40,7 +40,7 @@ public class DollarValueUserType implements UserType<DollarValue> {
} }
@Override @Override
public DollarValue nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public DollarValue nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return new DollarValue( rs.getBigDecimal( position ) ); return new DollarValue( rs.getBigDecimal( position ) );
} }
@ -50,7 +50,7 @@ public class DollarValueUserType implements UserType<DollarValue> {
PreparedStatement st, PreparedStatement st,
DollarValue value, DollarValue value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
st.setBigDecimal(index, value.getAmount()); st.setBigDecimal(index, value.getAmount());
} }

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -40,7 +40,7 @@ public class MyDateUserType implements UserType<MyDate> {
} }
@Override @Override
public MyDate nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public MyDate nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return new MyDate( rs.getDate( position ) ); return new MyDate( rs.getDate( position ) );
} }
@ -50,7 +50,7 @@ public class MyDateUserType implements UserType<MyDate> {
PreparedStatement st, PreparedStatement st,
MyDate value, MyDate value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
st.setDate(index, new java.sql.Date(value.getDate().getTime())); st.setDate(index, new java.sql.Date(value.getDate().getTime()));
} }

View File

@ -9,8 +9,8 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.orm.test.annotations.enumerated.enums.FirstLetter; import org.hibernate.orm.test.annotations.enumerated.enums.FirstLetter;
import org.hibernate.type.descriptor.WrapperOptions;
/** /**
* @author Janario Oliveira * @author Janario Oliveira
@ -23,7 +23,7 @@ public class FirstLetterType extends org.hibernate.type.EnumType<FirstLetter> {
} }
@Override @Override
public FirstLetter nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public FirstLetter nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String persistValue = (String) rs.getObject( position ); String persistValue = (String) rs.getObject( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -33,7 +33,7 @@ public class FirstLetterType extends org.hibernate.type.EnumType<FirstLetter> {
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, FirstLetter value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, FirstLetter value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( index, getSqlType() ); st.setNull( index, getSqlType() );

View File

@ -9,8 +9,8 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.orm.test.annotations.enumerated.enums.LastNumber; import org.hibernate.orm.test.annotations.enumerated.enums.LastNumber;
import org.hibernate.type.descriptor.WrapperOptions;
/** /**
* @author Janario Oliveira * @author Janario Oliveira
@ -23,7 +23,7 @@ public class LastNumberType extends org.hibernate.type.EnumType<LastNumber> {
} }
@Override @Override
public LastNumber nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public LastNumber nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String persistValue = (String) rs.getObject( position ); String persistValue = (String) rs.getObject( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -33,7 +33,7 @@ public class LastNumberType extends org.hibernate.type.EnumType<LastNumber> {
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, LastNumber value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, LastNumber value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( index, getSqlType() ); st.setNull( index, getSqlType() );

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -37,7 +37,7 @@ public class StateType implements UserType<State> {
} }
@Override @Override
public State nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public State nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
int result = rs.getInt( position ); int result = rs.getInt( position );
if ( rs.wasNull() ) return null; if ( rs.wasNull() ) return null;
@ -45,7 +45,7 @@ public class StateType implements UserType<State> {
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, State value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, State value, int index, WrapperOptions options)
throws HibernateException, SQLException { throws HibernateException, SQLException {
if (value == null) { if (value == null) {
st.setNull( index, Types.INTEGER ); st.setNull( index, Types.INTEGER );

View File

@ -4,7 +4,7 @@
*/ */
package org.hibernate.orm.test.annotations.type.dynamicparameterized; package org.hibernate.orm.test.annotations.type.dynamicparameterized;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.DynamicParameterizedType; import org.hibernate.usertype.DynamicParameterizedType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
@ -32,13 +32,13 @@ public class MyGenericType implements UserType<Object>, DynamicParameterizedType
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
st.setString( index, null ); st.setString( index, null );
} }
@Override @Override
public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Object nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return null; return null;
} }

View File

@ -11,8 +11,8 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import java.util.Properties; import java.util.Properties;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.models.spi.FieldDetails; import org.hibernate.models.spi.FieldDetails;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.DynamicParameterizedType; import org.hibernate.usertype.DynamicParameterizedType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
@ -79,13 +79,13 @@ public class MyStringType implements UserType<String>, DynamicParameterizedType
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, String value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
st.setString( index, this.value ); st.setString( index, this.value );
} }
@Override @Override
public String nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public String nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return rs.getString( position ); return rs.getString( position );
} }

View File

@ -13,11 +13,11 @@ import jakarta.persistence.ManyToOne;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.EnhancedUserType; import org.hibernate.usertype.EnhancedUserType;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -127,12 +127,12 @@ public class ManyToOneUniqueKeyReferenceWithCustomIdTest {
@Override @Override
public void nullSafeSet(PreparedStatement st, CustomId value, int position, public void nullSafeSet(PreparedStatement st, CustomId value, int position,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
st.setObject( position, value.toString(), getSqlType() ); st.setObject( position, value.toString(), getSqlType() );
} }
@Override @Override
public CustomId nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public CustomId nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String idValue = rs.getString( position ); String idValue = rs.getString( position );
return idValue != null ? fromStringValue( idValue ) : null; return idValue != null ? fromStringValue( idValue ) : null;

View File

@ -10,7 +10,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -39,13 +39,13 @@ public class MyUserType implements UserType<UUID> {
} }
@Override @Override
public UUID nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public UUID nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return null; return null;
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, UUID value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, UUID value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
} }

View File

@ -14,11 +14,11 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.resource.beans.container.spi.ExtendedBeanManager; import org.hibernate.resource.beans.container.spi.ExtendedBeanManager;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.util.ServiceRegistryUtil; import org.hibernate.testing.util.ServiceRegistryUtil;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.DynamicParameterizedType; import org.hibernate.usertype.DynamicParameterizedType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -91,14 +91,14 @@ public class ExtendedBeanManagerNotAvailableDuringCustomUserTypeInitTest {
} }
@Override @Override
public Object nullSafeGet(ResultSet rs, int i, SharedSessionContractImplementor sharedSessionContractImplementor) public Object nullSafeGet(ResultSet rs, int i, WrapperOptions sharedSessionContractImplementor)
throws SQLException { throws SQLException {
String xmldoc = rs.getString(i); String xmldoc = rs.getString(i);
return rs.wasNull() ? null : xmldoc; return rs.wasNull() ? null : xmldoc;
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if (value == null) { if (value == null) {
st.setNull(index, Types.OTHER); st.setNull(index, Types.OTHER);

View File

@ -10,8 +10,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import jakarta.inject.Singleton; import jakarta.inject.Singleton;
@ -58,13 +58,13 @@ public class UrlType implements UserType<URL> {
} }
@Override @Override
public URL nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public URL nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
throw new UnsupportedOperationException( "Not used" ); throw new UnsupportedOperationException( "Not used" );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, URL value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, URL value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
throw new UnsupportedOperationException( "Not used" ); throw new UnsupportedOperationException( "Not used" );
} }

View File

@ -49,6 +49,7 @@ public class ComponentBasicProxyTest {
@Test @Test
@JiraKey(value = "HHH-12791") @JiraKey(value = "HHH-12791")
public void testOnlyOneProxyClassGenerated(DomainModelScope domainModelScope, SessionFactoryScope sfScope) { public void testOnlyOneProxyClassGenerated(DomainModelScope domainModelScope, SessionFactoryScope sfScope) {
sfScope.getSessionFactory();
final PersistentClass personDescriptor = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() ); final PersistentClass personDescriptor = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
final CompositeTypeImplementor componentType = (CompositeTypeImplementor) personDescriptor.getIdentifierMapper().getType(); final CompositeTypeImplementor componentType = (CompositeTypeImplementor) personDescriptor.getIdentifierMapper().getType();
final EmbeddableValuedModelPart embedded = componentType.getMappingModelPart(); final EmbeddableValuedModelPart embedded = componentType.getMappingModelPart();

View File

@ -12,7 +12,6 @@ import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.EnhancedUserType; import org.hibernate.usertype.EnhancedUserType;
@ -57,7 +56,7 @@ public class ClassificationType implements EnhancedUserType<Classification>, Val
} }
@Override @Override
public Classification nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Classification nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
final int intValue = rs.getInt( position ); final int intValue = rs.getInt( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -67,7 +66,7 @@ public class ClassificationType implements EnhancedUserType<Classification>, Val
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Classification value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Classification value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( index, Types.INTEGER ); st.setNull( index, Types.INTEGER );

View File

@ -14,7 +14,7 @@ import java.util.Comparator;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.EnhancedUserType; import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -128,7 +128,7 @@ public class UserTypeComparableIdTest {
} }
@Override @Override
public CustomId nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public CustomId nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
Long value = rs.getLong( position ); Long value = rs.getLong( position );
@ -140,7 +140,7 @@ public class UserTypeComparableIdTest {
PreparedStatement preparedStatement, PreparedStatement preparedStatement,
CustomId customId, CustomId customId,
int index, int index,
SharedSessionContractImplementor sessionImplementor) throws SQLException { WrapperOptions sessionImplementor) throws SQLException {
if ( customId == null ) { if ( customId == null ) {
preparedStatement.setNull( index, Types.BIGINT ); preparedStatement.setNull( index, Types.BIGINT );
} }

View File

@ -17,7 +17,7 @@ import jakarta.persistence.Table;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.EnhancedUserType; import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -115,7 +115,7 @@ public class UserTypeNonComparableIdTest {
} }
@Override @Override
public CustomId nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public CustomId nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
Long value = rs.getLong( position ); Long value = rs.getLong( position );
@ -127,7 +127,7 @@ public class UserTypeNonComparableIdTest {
PreparedStatement preparedStatement, PreparedStatement preparedStatement,
CustomId customId, CustomId customId,
int index, int index,
SharedSessionContractImplementor sessionImplementor) throws SQLException { WrapperOptions sessionImplementor) throws SQLException {
if ( customId == null ) { if ( customId == null ) {
preparedStatement.setNull( index, Types.BIGINT ); preparedStatement.setNull( index, Types.BIGINT );
} }

View File

@ -15,8 +15,8 @@ import java.util.Objects;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -131,7 +131,7 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe
} }
@Override @Override
public Boolean nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Boolean nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return "Y".equals( rs.getString( position ) ); return "Y".equals( rs.getString( position ) );
} }
@ -141,7 +141,7 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe
PreparedStatement st, PreparedStatement st,
Boolean value, Boolean value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
st.setString(index, value ? "Y" : "N"); st.setString(index, value ? "Y" : "N");
} }

View File

@ -16,10 +16,10 @@ import java.util.List;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.query.TypedParameterValue; import org.hibernate.query.TypedParameterValue;
import org.hibernate.type.CustomType; import org.hibernate.type.CustomType;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
@ -140,7 +140,7 @@ public class TypedValueParametersTest {
public static final TagUserType INSTANCE = new TagUserType(); public static final TagUserType INSTANCE = new TagUserType();
@Override @Override
public void nullSafeSet(PreparedStatement statement, List<String> list, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { public void nullSafeSet(PreparedStatement statement, List<String> list, int index, WrapperOptions options) throws HibernateException, SQLException {
if ( list == null ) { if ( list == null ) {
statement.setNull( index, SqlTypes.VARCHAR ); statement.setNull( index, SqlTypes.VARCHAR );
} }
@ -159,7 +159,7 @@ public class TypedValueParametersTest {
} }
@Override @Override
public List<String> nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public List<String> nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String string = rs.getString( position ); String string = rs.getString( position );

View File

@ -16,8 +16,8 @@ import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
@ -127,7 +127,7 @@ public class RepeatedMappingUserTypeTests {
public SortedSet<Integer> nullSafeGet( public SortedSet<Integer> nullSafeGet(
ResultSet rs, ResultSet rs,
int position, int position,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
return convertToEntityAttribute( rs.getString( position ) ); return convertToEntityAttribute( rs.getString( position ) );
} }
@ -136,7 +136,7 @@ public class RepeatedMappingUserTypeTests {
PreparedStatement st, PreparedStatement st,
SortedSet<Integer> values, SortedSet<Integer> values,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
if ( values == null || values.isEmpty() ) { if ( values == null || values.isEmpty() ) {
st.setNull( index, SqlTypes.VARCHAR ); st.setNull( index, SqlTypes.VARCHAR );
return; return;

View File

@ -12,7 +12,7 @@ import java.sql.Types;
import java.util.BitSet; import java.util.BitSet;
import java.util.Objects; import java.util.Objects;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -47,7 +47,7 @@ public class BitSetUserType implements UserType<BitSet> {
@Override @Override
public BitSet nullSafeGet(ResultSet rs, int position, public BitSet nullSafeGet(ResultSet rs, int position,
SharedSessionContractImplementor session) WrapperOptions options)
throws SQLException { throws SQLException {
String columnValue = rs.getString(position); String columnValue = rs.getString(position);
if (rs.wasNull()) { if (rs.wasNull()) {
@ -60,7 +60,7 @@ public class BitSetUserType implements UserType<BitSet> {
@Override @Override
public void nullSafeSet(PreparedStatement st, BitSet value, int index, public void nullSafeSet(PreparedStatement st, BitSet value, int index,
SharedSessionContractImplementor session) WrapperOptions options)
throws SQLException { throws SQLException {
if (value == null) { if (value == null) {
log.debugv("Binding null to parameter {0} ",index); log.debugv("Binding null to parameter {0} ",index);

View File

@ -13,7 +13,7 @@ import java.util.Properties;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
@ -60,7 +60,7 @@ public class EnumUserType<T extends Enum<T>> implements UserType<T>, Parameteriz
} }
@Override @Override
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public T nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
final String name = rs.getString( position ); final String name = rs.getString( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -78,7 +78,7 @@ public class EnumUserType<T extends Enum<T>> implements UserType<T>, Parameteriz
PreparedStatement preparedStatement, PreparedStatement preparedStatement,
T value, T value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
if ( null == value ) { if ( null == value ) {
preparedStatement.setNull( index, Types.VARCHAR ); preparedStatement.setNull( index, Types.VARCHAR );
} }

View File

@ -13,8 +13,8 @@ import java.time.YearMonth;
import java.util.Objects; import java.util.Objects;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
@ -132,7 +132,7 @@ public class UserTypeFunctionsTest {
} }
@Override @Override
public YearMonth nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public YearMonth nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
int intValue = rs.getInt( position ); int intValue = rs.getInt( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -146,7 +146,7 @@ public class UserTypeFunctionsTest {
PreparedStatement st, PreparedStatement st,
YearMonth value, YearMonth value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( index, Types.INTEGER ); st.setNull( index, Types.INTEGER );
} }

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -37,13 +37,13 @@ public class RowIdType implements UserType<Object>{
} }
@Override @Override
public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Object nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return rs.getObject( position ); return rs.getObject( position );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }

View File

@ -12,11 +12,11 @@ import java.sql.Types;
import java.util.UUID; import java.util.UUID;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.BasicTypeRegistry; import org.hibernate.type.BasicTypeRegistry;
import org.hibernate.type.CustomType; import org.hibernate.type.CustomType;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.StringJavaType; import org.hibernate.type.descriptor.java.StringJavaType;
import org.hibernate.type.descriptor.java.UUIDJavaType; import org.hibernate.type.descriptor.java.UUIDJavaType;
import org.hibernate.type.descriptor.jdbc.BinaryJdbcType; import org.hibernate.type.descriptor.jdbc.BinaryJdbcType;
@ -139,12 +139,12 @@ public class BasicTypeRegistryTest extends BaseUnitTestCase {
} }
@Override @Override
public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) throws SQLException { public Object nullSafeGet(ResultSet rs, int position, WrapperOptions options) throws SQLException {
return null; return null;
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { public void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws HibernateException, SQLException {
} }
@Override @Override

View File

@ -10,8 +10,8 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.query.BindingContext; import org.hibernate.query.BindingContext;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
import org.hibernate.query.BindableType; import org.hibernate.query.BindableType;
import org.hibernate.query.sqm.SqmExpressible; import org.hibernate.query.sqm.SqmExpressible;
@ -70,15 +70,15 @@ public class ArrayType implements UserType<Array>, BindableType<Array>, BasicVal
} }
@Override @Override
public Array nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Array nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return jdbcType.getExtractor( javaType ).extract( rs, position, session ); return jdbcType.getExtractor( javaType ).extract( rs, position, options );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Array value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Array value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
jdbcType.getBinder( javaType ).bind( st, value, index, session ); jdbcType.getBinder( javaType ).bind( st, value, index, options );
} }
@Override @Override

View File

@ -12,7 +12,7 @@ import java.sql.Types;
import java.util.Objects; import java.util.Objects;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -49,7 +49,7 @@ public class StringWrapperUserType implements UserType<StringWrapper> {
} }
@Override @Override
public StringWrapper nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public StringWrapper nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String columnValue = (String) rs.getObject( position ); String columnValue = (String) rs.getObject( position );
log.debugv( "Result set column {0} value is {1}", position, columnValue ); log.debugv( "Result set column {0} value is {1}", position, columnValue );
@ -58,7 +58,7 @@ public class StringWrapperUserType implements UserType<StringWrapper> {
@Override @Override
public void nullSafeSet( public void nullSafeSet(
PreparedStatement st, StringWrapper value, int index, SharedSessionContractImplementor session) PreparedStatement st, StringWrapper value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
log.debugv("Binding null to parameter {0} ",index); log.debugv("Binding null to parameter {0} ",index);

View File

@ -4,8 +4,8 @@
*/ */
package org.hibernate.orm.test.type.contributor.usertype.hhh18787; package org.hibernate.orm.test.type.contributor.usertype.hhh18787;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.SqlTypes; import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
import java.io.Serializable; import java.io.Serializable;
@ -45,16 +45,16 @@ public class CustomDataType implements UserType<CustomData[]> {
} }
@Override @Override
public CustomData[] nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, public CustomData[] nullSafeGet(ResultSet rs, int position, WrapperOptions options)
Object owner) throws SQLException { throws SQLException {
final var customDataStr = rs.getString(position); final var customDataStr = rs.getString(position);
return rs.wasNull() ? new CustomData[0] : parseDataFromString(customDataStr); return rs.wasNull() ? new CustomData[0] : parseDataFromString(customDataStr);
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, CustomData[] value, int index, public void nullSafeSet(PreparedStatement st, CustomData[] value, int index, WrapperOptions options)
SharedSessionContractImplementor session) throws SQLException { throws SQLException {
if (value == null || value.length == 0) { if (value == null || value.length == 0) {
st.setNull(index, Types.VARCHAR); st.setNull(index, Types.VARCHAR);

View File

@ -12,7 +12,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
@ -47,14 +47,14 @@ public class DefaultValueIntegerType implements UserType<Integer>, Parameterized
} }
@Override @Override
public Integer nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Integer nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
Number result = (Number) rs.getObject( position ); Number result = (Number) rs.getObject( position );
return result == null ? defaultValue : Integer.valueOf( result.intValue() ); return result == null ? defaultValue : Integer.valueOf( result.intValue() );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Integer value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Integer value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null || defaultValue.equals( value ) ) { if ( value == null || defaultValue.equals( value ) ) {
log.trace( "binding null to parameter: " + index ); log.trace( "binding null to parameter: " + index );

View File

@ -14,6 +14,7 @@ import java.util.Objects;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.boot.MetadataBuilder; import org.hibernate.boot.MetadataBuilder;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserVersionType; import org.hibernate.usertype.UserVersionType;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -147,7 +148,7 @@ public class UserVersionTest extends BaseSessionFactoryFunctionalTest {
public CustomVersion nullSafeGet( public CustomVersion nullSafeGet(
ResultSet resultSet, ResultSet resultSet,
int position, int position,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
return new CustomVersion( resultSet.getLong( position ) ); return new CustomVersion( resultSet.getLong( position ) );
} }
@ -156,7 +157,7 @@ public class UserVersionTest extends BaseSessionFactoryFunctionalTest {
PreparedStatement statement, PreparedStatement statement,
CustomVersion value, CustomVersion value,
int index, int index,
SharedSessionContractImplementor session) throws SQLException { WrapperOptions options) throws SQLException {
statement.setLong( index, value.getRev() ); statement.setLong( index, value.getRev() );
} }

View File

@ -12,8 +12,8 @@ import java.sql.Types;
import java.util.Objects; import java.util.Objects;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.envers.RevisionType; import org.hibernate.envers.RevisionType;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -35,7 +35,7 @@ public class RevisionTypeType implements UserType<RevisionType>, Serializable {
} }
@Override @Override
public RevisionType nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public RevisionType nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
byte byteValue = rs.getByte( position ); byte byteValue = rs.getByte( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -45,7 +45,7 @@ public class RevisionTypeType implements UserType<RevisionType>, Serializable {
} }
@Override @Override
public void nullSafeSet(PreparedStatement preparedStatement, RevisionType value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement preparedStatement, RevisionType value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
preparedStatement.setNull( index, Types.TINYINT ); preparedStatement.setNull( index, Types.TINYINT );

View File

@ -12,7 +12,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.StringJavaType; import org.hibernate.type.descriptor.java.StringJavaType;
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.ParameterizedType;
@ -36,13 +36,13 @@ public class ParametrizedTestUserType implements UserType<String>, Parameterized
} }
@Override @Override
public String nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public String nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
final String string = rs.getString( position ); final String string = rs.getString( position );
return rs.wasNull() ? null : string; return rs.wasNull() ? null : string;
} }
public void nullSafeSet(PreparedStatement st, String value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, String value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value != null ) { if ( value != null ) {
if ( !value.startsWith( param1 ) ) { if ( !value.startsWith( param1 ) ) {
@ -53,7 +53,7 @@ public class ParametrizedTestUserType implements UserType<String>, Parameterized
} }
} }
VarcharJdbcType.INSTANCE.getBinder( StringJavaType.INSTANCE ) VarcharJdbcType.INSTANCE.getBinder( StringJavaType.INSTANCE )
.bind( st, value, index, session ); .bind( st, value, index, options );
} }
@Override @Override

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
/** /**
@ -43,7 +43,7 @@ public class CustomEnumUserType implements UserType<CustomEnum> {
} }
@Override @Override
public CustomEnum nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public CustomEnum nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
String name = rs.getString( position ); String name = rs.getString( position );
if ( rs.wasNull() ) { if ( rs.wasNull() ) {
@ -52,7 +52,7 @@ public class CustomEnumUserType implements UserType<CustomEnum> {
return CustomEnum.fromYesNo( name ); return CustomEnum.fromYesNo( name );
} }
public void nullSafeSet(PreparedStatement st, CustomEnum value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, CustomEnum value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
if ( value == null ) { if ( value == null ) {
st.setNull( index, Types.VARCHAR ); st.setNull( index, Types.VARCHAR );

View File

@ -11,7 +11,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.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
public class AgeType implements UserType<Age> { public class AgeType implements UserType<Age> {
@ -37,13 +37,13 @@ public class AgeType implements UserType<Age> {
} }
@Override @Override
public Age nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Age nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
return new Age( rs.getInt( position ) ); return new Age( rs.getInt( position ) );
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Age value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Age value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
st.setInt( index, value.getAgeInYears() ); st.setInt( index, value.getAgeInYears() );
} }

View File

@ -9,7 +9,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map; import java.util.Map;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
import org.hibernate.usertype.StaticUserTypeSupport; import org.hibernate.usertype.StaticUserTypeSupport;
@ -30,9 +30,9 @@ public class CommaDelimitedStringsMapType extends StaticUserTypeSupport<Map<Stri
} }
@Override @Override
public Map<String,String> nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) public Map<String,String> nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException { throws SQLException {
final Object extracted = getJdbcValueExtractor().extract( rs, position, session ); final Object extracted = getJdbcValueExtractor().extract( rs, position, options );
if ( extracted == null ) { if ( extracted == null ) {
return null; return null;
} }
@ -41,9 +41,9 @@ public class CommaDelimitedStringsMapType extends StaticUserTypeSupport<Map<Stri
} }
@Override @Override
public void nullSafeSet(PreparedStatement st, Map<String,String> value, int index, SharedSessionContractImplementor session) public void nullSafeSet(PreparedStatement st, Map<String,String> value, int index, WrapperOptions options)
throws SQLException { throws SQLException {
final String stringValue = getJavaType().toString( value ); final String stringValue = getJavaType().toString( value );
getJdbcValueBinder().bind( st, stringValue, index, session ); getJdbcValueBinder().bind( st, stringValue, index, options );
} }
} }