diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/PreparedStatementGroupSingleTable.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/PreparedStatementGroupSingleTable.java index bcbc765818..1a05f0bcb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/PreparedStatementGroupSingleTable.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/mutation/internal/PreparedStatementGroupSingleTable.java @@ -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 */ diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java index aaeada5e55..3a3995b4bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java @@ -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> } @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> } @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 diff --git a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java index 00f6a7e7c8..d5ed8c9f56 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java @@ -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 */ diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java b/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java index 2df9810830..9307712246 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java @@ -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 implements UserType { } @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 diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java b/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java index 0732c77ee5..53e85057a9 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java @@ -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 implements UserType { } @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 implements UserType { } @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 implements UserType { valueToBind = value; } - jdbcValueBinder.bind( st, valueToBind, index, session ); + jdbcValueBinder.bind( st, valueToBind, index, options ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java b/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java index bbe1c97ecb..d10910d9f8 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java @@ -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; * } * * @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); * } * * @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; * } * * @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); * } * * @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 { * * @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 { * 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 { * {@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() ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java index 02c6a232f0..71e2468af4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java @@ -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 { } @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 { PreparedStatement st, DollarValue value, int index, - SharedSessionContractImplementor session) throws SQLException { + WrapperOptions options) throws SQLException { st.setBigDecimal(index, value.getAmount()); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java index beabc3673c..1e75c822d1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java @@ -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 { } @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 { PreparedStatement st, MyDate value, int index, - SharedSessionContractImplementor session) throws SQLException { + WrapperOptions options) throws SQLException { st.setDate(index, new java.sql.Date(value.getDate().getTime())); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java index b9ea91d1e5..9d41084503 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java @@ -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 { } @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 { } @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() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java index eb9ed0bed5..b0c9b3d068 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java @@ -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 { } @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 { } @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() ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java index 7ee83bcca3..77e8817178 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java @@ -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 { } @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 { } @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 ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyGenericType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyGenericType.java index 88f5e1ac75..f12450b64c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyGenericType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyGenericType.java @@ -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, 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; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java index 0dd3327f8e..e53e6d7d45 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java @@ -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, 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 ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/associations/ManyToOneUniqueKeyReferenceWithCustomIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/associations/ManyToOneUniqueKeyReferenceWithCustomIdTest.java index 5433f41554..5f15d2bcd6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/associations/ManyToOneUniqueKeyReferenceWithCustomIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/associations/ManyToOneUniqueKeyReferenceWithCustomIdTest.java @@ -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; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/MyUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/MyUserType.java index dd6309db67..3e8186b506 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/MyUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/MyUserType.java @@ -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 { } @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 { } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/lifecycle/ExtendedBeanManagerNotAvailableDuringCustomUserTypeInitTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/lifecycle/ExtendedBeanManagerNotAvailableDuringCustomUserTypeInitTest.java index 8c02c3f0e2..5261c7a001 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/lifecycle/ExtendedBeanManagerNotAvailableDuringCustomUserTypeInitTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/lifecycle/ExtendedBeanManagerNotAvailableDuringCustomUserTypeInitTest.java @@ -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); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/type/UrlType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/type/UrlType.java index 945dfc6269..87249213b3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/type/UrlType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cdi/type/UrlType.java @@ -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 { } @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" ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/component/proxy/ComponentBasicProxyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/component/proxy/ComponentBasicProxyTest.java index 2fef0ff7aa..f24008b95b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/component/proxy/ComponentBasicProxyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/component/proxy/ComponentBasicProxyTest.java @@ -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(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java index a45617d3e9..307f858859 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java @@ -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, 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, 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 ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java index 7a8270d26a..f2ec6b7d9d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java @@ -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 ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java index be08997bd5..759cbf9d44 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java @@ -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 ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java index f65bf16e44..797c82b084 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java @@ -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"); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java index f41bdfd332..7d574b6a1c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java @@ -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 list, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { + public void nullSafeSet(PreparedStatement statement, List 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 nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) + public List nullSafeGet(ResultSet rs, int position, WrapperOptions options) throws SQLException { String string = rs.getString( position ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/RepeatedMappingUserTypeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/RepeatedMappingUserTypeTests.java index b7f5081aaa..77b3e506e5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/RepeatedMappingUserTypeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/RepeatedMappingUserTypeTests.java @@ -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 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 values, int index, - SharedSessionContractImplementor session) throws SQLException { + WrapperOptions options) throws SQLException { if ( values == null || values.isEmpty() ) { st.setNull( index, SqlTypes.VARCHAR ); return; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/bitset/BitSetUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/bitset/BitSetUserType.java index 58b9be4a7f..2ba092b245 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/bitset/BitSetUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/basic/bitset/BitSetUserType.java @@ -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 { @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 { @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); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java index 51c3e89588..42f927b9fe 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java @@ -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> implements UserType, 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> implements UserType, Parameteriz PreparedStatement preparedStatement, T value, int index, - SharedSessionContractImplementor session) throws SQLException { + WrapperOptions options) throws SQLException { if ( null == value ) { preparedStatement.setNull( index, Types.VARCHAR ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/UserTypeFunctionsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/UserTypeFunctionsTest.java index 336f4f5075..587a001f1e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/UserTypeFunctionsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/UserTypeFunctionsTest.java @@ -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 ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java index 943adf72aa..17eba010c8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java @@ -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{ } @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(); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java index 18a237607d..06edfae526 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java @@ -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 diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java index 6861c8877d..0b3530a2d7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java @@ -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, BindableType, 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 diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java index 816658ba70..d2cdffc0cf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java @@ -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 { } @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 { @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); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/hhh18787/CustomDataType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/hhh18787/CustomDataType.java index 9fdbe3623b..4f4572ffcd 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/hhh18787/CustomDataType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/hhh18787/CustomDataType.java @@ -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 { } @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); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java index a68523db86..c421d3f821 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java @@ -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, 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 ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/version/UserVersionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/version/UserVersionTest.java index 6fe78b5f76..47337846f2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/version/UserVersionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/version/UserVersionTest.java @@ -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() ); } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java index 56b739c98b..b0e1202fc3 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java @@ -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, 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, 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 ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java index 685a0a5606..f339df9d61 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java @@ -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, 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, Parameterized } } VarcharJdbcType.INSTANCE.getBinder( StringJavaType.INSTANCE ) - .bind( st, value, index, session ); + .bind( st, value, index, options ); } @Override diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java index 217722b9de..b998df05a9 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java @@ -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 { } @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 { 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 ); diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java index ea96a22100..842ea607d0 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java @@ -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 { @@ -37,13 +37,13 @@ public class AgeType implements UserType { } @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() ); } diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/collectionbasictype/CommaDelimitedStringsMapType.java b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/collectionbasictype/CommaDelimitedStringsMapType.java index a8b3d7de24..d9c0c2178b 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/collectionbasictype/CommaDelimitedStringsMapType.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/processor/test/collectionbasictype/CommaDelimitedStringsMapType.java @@ -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 nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session) + public Map 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 value, int index, SharedSessionContractImplementor session) + public void nullSafeSet(PreparedStatement st, Map 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 ); } }