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;
/**
* {@link PreparedStatementGroup} implementation for cases where we
* have just a single operation
* {@link org.hibernate.engine.jdbc.mutation.group.PreparedStatementGroup}
* implementation for cases where we have just a single operation
*
* @author Steve Ebersole
*/

View File

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

View File

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

View File

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

View File

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

View File

@ -15,6 +15,7 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
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.jdbc.JdbcType;
import org.hibernate.type.spi.TypeConfiguration;
@ -63,16 +64,14 @@ import org.hibernate.type.spi.TypeConfiguration;
* }
*
* &#64;Override
* public Period nullSafeGet(ResultSet rs, int position,
* SharedSessionContractImplementor session)
* public Period nullSafeGet(ResultSet rs, int position, WrapperOptions options)
* throws SQLException {
* String string = rs.getString(position);
* return rs.wasNull() ? null : Period.parse(string);
* }
*
* &#64;Override
* public void nullSafeSet(PreparedStatement st, Period value, int index,
* SharedSessionContractImplementor session)
* public void nullSafeSet(PreparedStatement st, Period value, int index, WrapperOptions options)
* throws SQLException {
* if ( value == null ) {
* st.setNull(index, VARCHAR);
@ -169,16 +168,14 @@ import org.hibernate.type.spi.TypeConfiguration;
* }
*
* &#64;Override
* public BitSet nullSafeGet(ResultSet rs, int position,
* SharedSessionContractImplementor session)
* public BitSet nullSafeGet(ResultSet rs, int position, WrapperOptions options)
* throws SQLException {
* String string = rs.getString(position);
* return rs.wasNull()? null : parseBitSet(columnValue);
* }
*
* &#64;Override
* public void nullSafeSet(PreparedStatement st, BitSet bitSet, int index,
* SharedSessionContractImplementor session)
* public void nullSafeSet(PreparedStatement st, BitSet bitSet, int index, WrapperOptions options)
* throws SQLException {
* if (bitSet == null) {
* st.setNull(index, VARCHAR);
@ -296,7 +293,7 @@ public interface UserType<J> {
*
* @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)
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
* {@linkplain #returnedClass returned class}.
*/
default J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
default J nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
J result = rs.getObject( position, returnedClass() );
return rs.wasNull() ? null : result;
@ -330,9 +327,28 @@ public interface UserType<J> {
* {@link PreparedStatement#setObject(int, Object, int)}
* with the given {@code position} and {@code value} and
* 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)
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 ) {
st.setNull( position, getSqlType() );
}

View File

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

View File

@ -11,7 +11,7 @@ import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType;
/**
@ -40,7 +40,7 @@ public class MyDateUserType implements UserType<MyDate> {
}
@Override
public MyDate nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public MyDate nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
return new MyDate( rs.getDate( position ) );
}
@ -50,7 +50,7 @@ public class MyDateUserType implements UserType<MyDate> {
PreparedStatement st,
MyDate value,
int index,
SharedSessionContractImplementor session) throws SQLException {
WrapperOptions options) throws SQLException {
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.Types;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.orm.test.annotations.enumerated.enums.FirstLetter;
import org.hibernate.type.descriptor.WrapperOptions;
/**
* @author Janario Oliveira
@ -23,7 +23,7 @@ public class FirstLetterType extends org.hibernate.type.EnumType<FirstLetter> {
}
@Override
public FirstLetter nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public FirstLetter nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
String persistValue = (String) rs.getObject( position );
if ( rs.wasNull() ) {
@ -33,7 +33,7 @@ public class FirstLetterType extends org.hibernate.type.EnumType<FirstLetter> {
}
@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 {
if ( value == null ) {
st.setNull( index, getSqlType() );

View File

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

View File

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

View File

@ -4,7 +4,7 @@
*/
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.UserType;
@ -32,13 +32,13 @@ public class MyGenericType implements UserType<Object>, DynamicParameterizedType
}
@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 {
st.setString( index, null );
}
@Override
public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public Object nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
return null;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@ import jakarta.persistence.Table;
import org.hibernate.HibernateException;
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.testing.orm.junit.JiraKey;
@ -115,7 +115,7 @@ public class UserTypeNonComparableIdTest {
}
@Override
public CustomId nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public CustomId nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
Long value = rs.getLong( position );
@ -127,7 +127,7 @@ public class UserTypeNonComparableIdTest {
PreparedStatement preparedStatement,
CustomId customId,
int index,
SharedSessionContractImplementor sessionImplementor) throws SQLException {
WrapperOptions sessionImplementor) throws SQLException {
if ( customId == null ) {
preparedStatement.setNull( index, Types.BIGINT );
}

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import java.sql.Types;
import java.util.BitSet;
import java.util.Objects;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.UserType;
import org.jboss.logging.Logger;
@ -47,7 +47,7 @@ public class BitSetUserType implements UserType<BitSet> {
@Override
public BitSet nullSafeGet(ResultSet rs, int position,
SharedSessionContractImplementor session)
WrapperOptions options)
throws SQLException {
String columnValue = rs.getString(position);
if (rs.wasNull()) {
@ -60,7 +60,7 @@ public class BitSetUserType implements UserType<BitSet> {
@Override
public void nullSafeSet(PreparedStatement st, BitSet value, int index,
SharedSessionContractImplementor session)
WrapperOptions options)
throws SQLException {
if (value == null) {
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.MappingException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType;
@ -60,7 +60,7 @@ public class EnumUserType<T extends Enum<T>> implements UserType<T>, Parameteriz
}
@Override
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public T nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
final String name = rs.getString( position );
if ( rs.wasNull() ) {
@ -78,7 +78,7 @@ public class EnumUserType<T extends Enum<T>> implements UserType<T>, Parameteriz
PreparedStatement preparedStatement,
T value,
int index,
SharedSessionContractImplementor session) throws SQLException {
WrapperOptions options) throws SQLException {
if ( null == value ) {
preparedStatement.setNull( index, Types.VARCHAR );
}

View File

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

View File

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

View File

@ -12,11 +12,11 @@ import java.sql.Types;
import java.util.UUID;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.BasicType;
import org.hibernate.type.BasicTypeRegistry;
import org.hibernate.type.CustomType;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.StringJavaType;
import org.hibernate.type.descriptor.java.UUIDJavaType;
import org.hibernate.type.descriptor.jdbc.BinaryJdbcType;
@ -139,12 +139,12 @@ public class BasicTypeRegistryTest extends BaseUnitTestCase {
}
@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;
}
@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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import java.sql.Types;
import java.util.Properties;
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.UserType;
@ -47,14 +47,14 @@ public class DefaultValueIntegerType implements UserType<Integer>, Parameterized
}
@Override
public Integer nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session)
public Integer nullSafeGet(ResultSet rs, int position, WrapperOptions options)
throws SQLException {
Number result = (Number) rs.getObject( position );
return result == null ? defaultValue : Integer.valueOf( result.intValue() );
}
@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 {
if ( value == null || defaultValue.equals( value ) ) {
log.trace( "binding null to parameter: " + index );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
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.usertype.StaticUserTypeSupport;
@ -30,9 +30,9 @@ public class CommaDelimitedStringsMapType extends StaticUserTypeSupport<Map<Stri
}
@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 {
final Object extracted = getJdbcValueExtractor().extract( rs, position, session );
final Object extracted = getJdbcValueExtractor().extract( rs, position, options );
if ( extracted == null ) {
return null;
}
@ -41,9 +41,9 @@ public class CommaDelimitedStringsMapType extends StaticUserTypeSupport<Map<Stri
}
@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 {
final String stringValue = getJavaType().toString( value );
getJdbcValueBinder().bind( st, stringValue, index, session );
getJdbcValueBinder().bind( st, stringValue, index, options );
}
}