diff --git a/documentation/src/test/java/org/hibernate/userguide/hql/HQLTest.java b/documentation/src/test/java/org/hibernate/userguide/hql/HQLTest.java index 775b040039..1b290f9544 100644 --- a/documentation/src/test/java/org/hibernate/userguide/hql/HQLTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/hql/HQLTest.java @@ -33,7 +33,6 @@ import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; import org.hibernate.userguide.model.AddressType; import org.hibernate.userguide.model.Call; import org.hibernate.userguide.model.CreditCardPayment; diff --git a/documentation/src/test/java/org/hibernate/userguide/sql/SQLTest.java b/documentation/src/test/java/org/hibernate/userguide/sql/SQLTest.java index cb1ac11e4e..e171cacdf9 100644 --- a/documentation/src/test/java/org/hibernate/userguide/sql/SQLTest.java +++ b/documentation/src/test/java/org/hibernate/userguide/sql/SQLTest.java @@ -20,9 +20,7 @@ import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException; import org.hibernate.transform.Transformers; -import org.hibernate.type.LongType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; import org.hibernate.userguide.model.AddressType; import org.hibernate.userguide.model.Call; import org.hibernate.userguide.model.CreditCardPayment; diff --git a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java index 2314457143..9f07f6ec42 100644 --- a/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/SharedSessionContract.java @@ -8,6 +8,7 @@ package org.hibernate; import java.io.Serializable; +import jakarta.persistence.StoredProcedureQuery; import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaDelete; import jakarta.persistence.criteria.CriteriaQuery; @@ -17,6 +18,7 @@ import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.Work; import org.hibernate.procedure.ProcedureCall; import org.hibernate.query.QueryProducer; +import org.hibernate.query.UnknownSqlResultSetMappingException; import org.hibernate.query.criteria.HibernateCriteriaBuilder; /** @@ -122,6 +124,47 @@ public interface SharedSessionContract extends QueryProducer, Serializable { */ ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings); + /** + * Gets a ProcedureCall based on a named template + * + * @param name The name given to the template + * + * @return The ProcedureCall + * + * @see jakarta.persistence.NamedStoredProcedureQuery + */ + ProcedureCall createNamedStoredProcedureQuery(String name); + + /** + * Creates a call to a stored procedure. + * + * @param procedureName The name of the procedure. + * + * @return The representation of the procedure call. + */ + ProcedureCall createStoredProcedureQuery(String procedureName); + + /** + * Creates a call to a stored procedure with specific result set entity mappings. Each class named + * is considered a "root return". + * + * @param procedureName The name of the procedure. + * @param resultClasses The entity(s) to map the result on to. + * + * @return The representation of the procedure call. + */ + ProcedureCall createStoredProcedureQuery(String procedureName, Class... resultClasses); + + /** + * Creates a call to a stored procedure with specific result set entity mappings. + * + * @param procedureName The name of the procedure. + * @param resultSetMappings The explicit result set mapping(s) to use for mapping the results + * + * @return The representation of the procedure call. + */ + ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings); + /** * Get the Session-level JDBC batch size for the current Session. * Overrides the SessionFactory JDBC batch size defined by the {@code hibernate.default_batch_fetch_size} configuration property for the scope of the current {@code Session}. diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index fb69404084..eb5e8730b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -152,12 +152,9 @@ import org.hibernate.tuple.GeneratedValueGeneration; import org.hibernate.tuple.GenerationTiming; import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.BasicType; -import org.hibernate.type.BlobType; -import org.hibernate.type.ClobType; import org.hibernate.type.ComponentType; import org.hibernate.type.CustomType; import org.hibernate.type.ForeignKeyDirection; -import org.hibernate.type.NClobType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.UserType; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/function/CommonFunctionFactory.java b/hibernate-core/src/main/java/org/hibernate/dialect/function/CommonFunctionFactory.java index c8d079c310..4edb83fa8f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/function/CommonFunctionFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/function/CommonFunctionFactory.java @@ -27,7 +27,6 @@ import org.hibernate.sql.ast.SqlAstNodeRenderingMode; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.type.BasicType; import org.hibernate.type.BasicTypeRegistry; -import org.hibernate.type.DoubleType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java index c22c5a392d..c49bb0e84b 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SessionDelegatorBaseImpl.java @@ -519,22 +519,22 @@ public class SessionDelegatorBaseImpl implements SessionImplementor { } @Override - public StoredProcedureQuery createNamedStoredProcedureQuery(String name) { + public ProcedureCall createNamedStoredProcedureQuery(String name) { return delegate.createNamedStoredProcedureQuery( name ); } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName) { + public ProcedureCall createStoredProcedureQuery(String procedureName) { return delegate.createStoredProcedureQuery( procedureName ); } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) { + public ProcedureCall createStoredProcedureQuery(String procedureName, Class... resultClasses) { return delegate.createStoredProcedureQuery( procedureName, resultClasses ); } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) { + public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings) { return delegate.createStoredProcedureQuery( procedureName, resultSetMappings ); } diff --git a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java index 8f359f7166..603334ec37 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/MultipleHiLoPerTableGenerator.java @@ -43,9 +43,7 @@ import org.hibernate.mapping.PrimaryKey; import org.hibernate.mapping.Table; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.BasicTypeRegistry; -import org.hibernate.type.LongType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; import org.hibernate.type.Type; /** diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java index bb7d0d1687..b301c684a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableGenerator.java @@ -51,9 +51,7 @@ import org.hibernate.mapping.PrimaryKey; import org.hibernate.mapping.Table; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.BasicTypeRegistry; -import org.hibernate.type.LongType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; import org.hibernate.type.Type; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java index 0da660a89e..23559472e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java +++ b/hibernate-core/src/main/java/org/hibernate/id/enhanced/TableStructure.java @@ -35,7 +35,6 @@ import org.hibernate.id.IntegralDataTypeHolder; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.jdbc.AbstractReturningWork; import org.hibernate.mapping.Table; -import org.hibernate.type.LongType; import org.hibernate.type.StandardBasicTypes; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java index ac3544eabc..6ac8c25d79 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractSharedSessionContract.java @@ -883,6 +883,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont return procedureCall; } + @Override + public ProcedureCall createNamedStoredProcedureQuery(String name) { + return getNamedProcedureCall( name ); + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // dynamic ProcedureCall support @@ -914,6 +919,33 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont return procedureCall; } + @Override + @SuppressWarnings("UnnecessaryLocalVariable") + public ProcedureCall createStoredProcedureQuery(String procedureName) { + checkOpen(); + final ProcedureCall procedureCall = new ProcedureCallImpl( this, procedureName ); +// call.setComment( "Dynamic stored procedure call" ); + return procedureCall; + } + + @Override + @SuppressWarnings("UnnecessaryLocalVariable") + public ProcedureCall createStoredProcedureQuery(String procedureName, Class... resultClasses) { + checkOpen(); + final ProcedureCall procedureCall = new ProcedureCallImpl( this, procedureName, resultClasses ); +// call.setComment( "Dynamic stored procedure call" ); + return procedureCall; + } + + @Override + @SuppressWarnings("UnnecessaryLocalVariable") + public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings) { + checkOpen(); + final ProcedureCall procedureCall = new ProcedureCallImpl( this, procedureName, resultSetMappings ); +// call.setComment( "Dynamic stored procedure call" ); + return procedureCall; + } + protected abstract Object load(String entityName, Object identifier); @Override diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index ea01657106..1a7f6b18b2 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -2563,7 +2563,7 @@ public class SessionImpl } @Override - public StoredProcedureQuery createNamedStoredProcedureQuery(String name) { + public ProcedureCall createNamedStoredProcedureQuery(String name) { checkOpen(); try { final NamedCallableQueryMemento memento = getFactory().getQueryEngine() @@ -2580,7 +2580,7 @@ public class SessionImpl } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName) { + public ProcedureCall createStoredProcedureQuery(String procedureName) { try { return createStoredProcedureCall( procedureName ); } @@ -2590,7 +2590,7 @@ public class SessionImpl } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) { + public ProcedureCall createStoredProcedureQuery(String procedureName, Class... resultClasses) { try { return createStoredProcedureCall( procedureName, resultClasses ); } @@ -2600,7 +2600,7 @@ public class SessionImpl } @Override - public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) { + public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings) { checkOpen(); try { try { diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java index b079320640..1132749f14 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java @@ -47,7 +47,6 @@ import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.basic.BasicResult; import org.hibernate.sql.results.internal.RowTransformerDatabaseSnapshotImpl; import org.hibernate.sql.results.spi.ListResultsConsumer; -import org.hibernate.type.IntegerType; import org.hibernate.type.StandardBasicTypes; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java index fbcc3fa328..7bae2e78f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/ProcedureCall.java @@ -6,9 +6,15 @@ */ package org.hibernate.procedure; +import java.util.Calendar; +import java.util.Date; import java.util.List; + +import jakarta.persistence.FlushModeType; +import jakarta.persistence.Parameter; import jakarta.persistence.ParameterMode; import jakarta.persistence.StoredProcedureQuery; +import jakarta.persistence.TemporalType; import org.hibernate.MappingException; import org.hibernate.SynchronizeableQuery; @@ -16,6 +22,7 @@ import org.hibernate.procedure.spi.NamedCallableQueryMemento; import org.hibernate.query.CommonQueryContract; import org.hibernate.query.procedure.ProcedureParameter; import org.hibernate.query.named.NameableQuery; +import org.hibernate.type.BasicTypeReference; /** * Defines support for executing database stored procedures and functions. @@ -100,15 +107,22 @@ public interface ProcedureCall ProcedureParameter registerParameter(int position, Class type, ParameterMode mode); /** - * Chained form of {@link #registerParameter(int, Class, jakarta.persistence.ParameterMode)} + * Basic form for registering a positional parameter. * * @param position The position - * @param type The Java type of the parameter + * @param type The type reference of the parameter type * @param mode The parameter mode (in, out, inout) + * @param The parameterized Java type of the parameter. * - * @return {@code this}, for method chaining + * @return The parameter registration memento */ - ProcedureCall registerParameter0(int position, Class type, ParameterMode mode); + ProcedureParameter registerParameter(int position, BasicTypeReference type, ParameterMode mode); + + /** + * Like {@link #registerStoredProcedureParameter(int, Class, ParameterMode)} but a basic type reference is given + * instead of a class for the parameter type. + */ + ProcedureCall registerStoredProcedureParameter(int position, BasicTypeReference type, ParameterMode mode); /** * Retrieve a previously registered parameter memento by the position under which it was registered. @@ -139,20 +153,27 @@ public interface ProcedureCall throws NamedParametersNotSupportedException; /** - * Chained form of {@link #registerParameter(String, Class, jakarta.persistence.ParameterMode)} + * Basic form for registering a named parameter. * * @param parameterName The parameter name - * @param type The Java type of the parameter + * @param type The type reference of the parameter type * @param mode The parameter mode (in, out, inout) + * @param The parameterized Java type of the parameter. * * @return The parameter registration memento * * @throws NamedParametersNotSupportedException When the underlying database is known to not support * named procedure parameters. */ - ProcedureCall registerParameter0(String parameterName, Class type, ParameterMode mode) + ProcedureParameter registerParameter(String parameterName, BasicTypeReference type, ParameterMode mode) throws NamedParametersNotSupportedException; + /** + * Like {@link #registerStoredProcedureParameter(String, Class, ParameterMode)} but a basic type reference is given + * instead of a class for the parameter type. + */ + ProcedureCall registerStoredProcedureParameter(String parameterName, BasicTypeReference type, ParameterMode mode); + /** * Retrieve a previously registered parameter memento by the name under which it was registered. * @@ -191,6 +212,10 @@ public interface ProcedureCall getOutputs().release(); } + /* + Covariant overrides + */ + @Override ProcedureCall addSynchronizedQuerySpace(String querySpace); @@ -202,4 +227,43 @@ public interface ProcedureCall @Override NamedCallableQueryMemento toMemento(String name); + + @Override + ProcedureCall setHint(String hintName, Object value); + + @Override + ProcedureCall setParameter( Parameter param, T value); + + @Override + ProcedureCall setParameter(Parameter param, Calendar value, TemporalType temporalType); + + @Override + ProcedureCall setParameter(Parameter param, Date value, TemporalType temporalType); + + @Override + ProcedureCall setParameter(String name, Object value); + + @Override + ProcedureCall setParameter(String name, Calendar value, TemporalType temporalType); + + @Override + ProcedureCall setParameter(String name, Date value, TemporalType temporalType); + + @Override + ProcedureCall setParameter(int position, Object value); + + @Override + ProcedureCall setParameter(int position, Calendar value, TemporalType temporalType); + + @Override + ProcedureCall setParameter(int position, Date value, TemporalType temporalType); + + @Override + ProcedureCall setFlushMode(FlushModeType flushMode); + + @Override + ProcedureCall registerStoredProcedureParameter(int position, Class type, ParameterMode mode); + + @Override + ProcedureCall registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode); } diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java index 52eb4aa05c..5b603080a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ProcedureCallImpl.java @@ -65,6 +65,7 @@ import org.hibernate.result.UpdateCountOutput; import org.hibernate.result.spi.ResultContext; import org.hibernate.sql.exec.spi.JdbcCall; import org.hibernate.sql.results.NoMoreOutputsException; +import org.hibernate.type.BasicType; import org.hibernate.type.BasicTypeReference; import org.jboss.logging.Logger; @@ -358,23 +359,77 @@ public class ProcedureCallImpl } @Override - @SuppressWarnings("unchecked") + public ProcedureCallImplementor registerStoredProcedureParameter( + int position, + BasicTypeReference type, + ParameterMode mode) { + getSession().checkOpen( true ); + + try { + registerParameter( position, type, mode ); + } + catch (HibernateException he) { + throw getSession().getExceptionConverter().convert( he ); + } + catch (RuntimeException e) { + getSession().markForRollbackOnly(); + throw e; + } + + return this; + } + + @Override + public ProcedureCallImplementor registerStoredProcedureParameter( + String parameterName, + BasicTypeReference type, + ParameterMode mode) { + getSession().checkOpen( true ); + try { + registerParameter( parameterName, type, mode ); + } + catch (HibernateException he) { + throw getSession().getExceptionConverter().convert( he ); + } + catch (RuntimeException e) { + getSession().markForRollbackOnly(); + throw e; + } + + return this; + } + + @Override public ProcedureParameter registerParameter(int position, Class javaType, ParameterMode mode) { - final ProcedureParameterImpl procedureParameter = new ProcedureParameterImpl( + final AllowableParameterType parameterType = getSessionFactory().getDomainModel().resolveQueryParameterType( + javaType + ); + final ProcedureParameterImpl procedureParameter = new ProcedureParameterImpl<>( position, mode, - javaType, - getSessionFactory().getDomainModel().resolveQueryParameterType( javaType ) + parameterType.getJavaType(), + parameterType ); registerParameter( procedureParameter ); return procedureParameter; } @Override - @SuppressWarnings("unchecked") - public ProcedureCall registerParameter0(int position, Class type, ParameterMode mode) { - registerParameter( position, type, mode ); - return this; + public ProcedureParameter registerParameter( + int position, + BasicTypeReference typeReference, + ParameterMode mode) { + final BasicType basicType = getSessionFactory().getTypeConfiguration() + .getBasicTypeRegistry() + .resolve( typeReference ); + final ProcedureParameterImpl procedureParameter = new ProcedureParameterImpl<>( + position, + mode, + basicType.getJavaType(), + basicType + ); + registerParameter( procedureParameter ); + return procedureParameter; } private void registerParameter(ProcedureParameterImplementor parameter) { @@ -389,11 +444,14 @@ public class ProcedureCallImpl @Override @SuppressWarnings("unchecked") public ProcedureParameterImplementor registerParameter(String name, Class javaType, ParameterMode mode) { + final AllowableParameterType parameterType = getSessionFactory().getDomainModel().resolveQueryParameterType( + javaType + ); final ProcedureParameterImpl parameter = new ProcedureParameterImpl( name, mode, - javaType, - getSessionFactory().getDomainModel().resolveQueryParameterType( javaType ) + parameterType.getJavaType(), + parameterType ); registerParameter( parameter ); @@ -403,9 +461,23 @@ public class ProcedureCallImpl @Override @SuppressWarnings("unchecked") - public ProcedureCall registerParameter0(String name, Class type, ParameterMode mode) { - registerParameter( name, type, mode ); - return this; + public ProcedureParameterImplementor registerParameter( + String name, + BasicTypeReference typeReference, + ParameterMode mode) { + final BasicType basicType = getSessionFactory().getTypeConfiguration() + .getBasicTypeRegistry() + .resolve( typeReference ); + final ProcedureParameterImpl parameter = new ProcedureParameterImpl( + name, + mode, + basicType.getJavaType(), + basicType + ); + + registerParameter( parameter ); + + return parameter; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/spi/ProcedureCallImplementor.java b/hibernate-core/src/main/java/org/hibernate/procedure/spi/ProcedureCallImplementor.java index 7e13844013..04ac900f8b 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/spi/ProcedureCallImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/spi/ProcedureCallImplementor.java @@ -16,6 +16,7 @@ import jakarta.persistence.TemporalType; import org.hibernate.procedure.ProcedureCall; import org.hibernate.query.spi.QueryImplementor; +import org.hibernate.type.BasicTypeReference; /** * @author Steve Ebersole @@ -33,6 +34,12 @@ public interface ProcedureCallImplementor extends ProcedureCall, QueryImpleme return uniqueResult(); } + @Override + ProcedureCallImplementor registerStoredProcedureParameter(int position, BasicTypeReference type, ParameterMode mode); + + @Override + ProcedureCallImplementor registerStoredProcedureParameter(String parameterName, BasicTypeReference type, ParameterMode mode); + @Override ProcedureCallImplementor setHint(String hintName, Object value); @@ -71,4 +78,5 @@ public interface ProcedureCallImplementor extends ProcedureCall, QueryImpleme @Override ProcedureCallImplementor registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode); + } diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/BindingTypeHelper.java b/hibernate-core/src/main/java/org/hibernate/query/internal/BindingTypeHelper.java index ce0fa9bd4d..6a2cdfd0f6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/BindingTypeHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/BindingTypeHelper.java @@ -15,14 +15,7 @@ import jakarta.persistence.TemporalType; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.model.domain.AllowableParameterType; -import org.hibernate.type.CalendarDateType; -import org.hibernate.type.CalendarTimeType; -import org.hibernate.type.CalendarType; -import org.hibernate.type.InstantType; -import org.hibernate.type.OffsetDateTimeType; -import org.hibernate.type.OffsetTimeType; -import org.hibernate.type.TimestampType; -import org.hibernate.type.ZonedDateTimeType; +import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.java.TemporalJavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; @@ -59,54 +52,10 @@ public class BindingTypeHelper { return declaredParameterType; } - public AllowableParameterType determineTypeForTemporalType(TemporalType temporalType, AllowableParameterType baseType, Object bindValue) { - // todo : for 6.0 make TemporalType part of org.hibernate.type.descriptor.java.JdbcRecommendedSqlTypeMappingContext - // then we can just ask the org.hibernate.type.basic.BasicTypeFactory to handle this based on its registry - // - // - or for 6.0 make TemporalType part of the state for those BasicType impls dealing with date/time types - // - // - or for 6.0 make TemporalType part of Binder contract - // - // - or add a org.hibernate.type.TemporalType#getVariant(TemporalType) - // - // - or ... - - // todo : (5.2) review Java type handling for sanity. This part was done quickly ;) - - final Class javaType; - - // Determine the "value java type" : - // prefer to leverage the bindValue java type (if bindValue not null), - // followed by the java type reported by the baseType, - // fallback to java.sql.Timestamp - - if ( bindValue != null ) { - javaType = bindValue.getClass(); - } - else if ( baseType != null ) { - javaType = baseType.getExpressableJavaTypeDescriptor().getJavaTypeClass(); - } - else { - javaType = java.sql.Timestamp.class; - } - - switch ( temporalType ) { - case TIMESTAMP: { - return resolveTimestampTemporalTypeVariant( javaType, baseType ); - } - case DATE: { - return resolveDateTemporalTypeVariant( javaType, baseType ); - } - case TIME: { - return resolveTimeTemporalTypeVariant( javaType, baseType ); - } - default: { - throw new IllegalArgumentException( "Unexpected TemporalType [" + temporalType + "]; expecting TIMESTAMP, DATE or TIME" ); - } - } - } - - public JdbcMapping resolveBindType(Object value, JdbcMapping baseType) { + public JdbcMapping resolveBindType( + Object value, + JdbcMapping baseType, + TypeConfiguration typeConfiguration) { if ( value == null || !( baseType.getJavaTypeDescriptor() instanceof TemporalJavaTypeDescriptor ) ) { return baseType; } @@ -115,13 +64,13 @@ public class BindingTypeHelper { final TemporalType temporalType = ( (TemporalJavaTypeDescriptor) baseType.getJavaTypeDescriptor() ).getPrecision(); switch ( temporalType ) { case TIMESTAMP: { - return (JdbcMapping) resolveTimestampTemporalTypeVariant( javaType, (AllowableParameterType) baseType ); + return (JdbcMapping) resolveTimestampTemporalTypeVariant( javaType, (AllowableParameterType) baseType, typeConfiguration ); } case DATE: { - return (JdbcMapping) resolveDateTemporalTypeVariant( javaType, (AllowableParameterType) baseType ); + return (JdbcMapping) resolveDateTemporalTypeVariant( javaType, (AllowableParameterType) baseType, typeConfiguration ); } case TIME: { - return (JdbcMapping) resolveTimeTemporalTypeVariant( javaType, (AllowableParameterType) baseType ); + return (JdbcMapping) resolveTimeTemporalTypeVariant( javaType, (AllowableParameterType) baseType, typeConfiguration ); } default: { throw new IllegalArgumentException( "Unexpected TemporalType [" + temporalType + "]; expecting TIMESTAMP, DATE or TIME" ); @@ -129,74 +78,83 @@ public class BindingTypeHelper { } } - public AllowableParameterType resolveTimestampTemporalTypeVariant(Class javaType, AllowableParameterType baseType) { + public AllowableParameterType resolveTimestampTemporalTypeVariant( + Class javaType, + AllowableParameterType baseType, + TypeConfiguration typeConfiguration) { //noinspection unchecked if ( baseType.getExpressableJavaTypeDescriptor().getJavaTypeClass().isAssignableFrom( javaType ) ) { return baseType; } if ( Calendar.class.isAssignableFrom( javaType ) ) { - return CalendarType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR ); } if ( java.util.Date.class.isAssignableFrom( javaType ) ) { - return TimestampType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.TIMESTAMP ); } if ( Instant.class.isAssignableFrom( javaType ) ) { - return InstantType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.INSTANT ); } if ( OffsetDateTime.class.isAssignableFrom( javaType ) ) { - return OffsetDateTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_DATE_TIME ); } if ( ZonedDateTime.class.isAssignableFrom( javaType ) ) { - return ZonedDateTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.ZONED_DATE_TIME ); } if ( OffsetTime.class.isAssignableFrom( javaType ) ) { - return OffsetTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_TIME ); } throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#TIMESTAMP" ); } - public AllowableParameterType resolveDateTemporalTypeVariant(Class javaType, AllowableParameterType baseType) { + public AllowableParameterType resolveDateTemporalTypeVariant( + Class javaType, + AllowableParameterType baseType, + TypeConfiguration typeConfiguration) { if ( baseType.getExpressableJavaTypeDescriptor().getJavaTypeClass().isAssignableFrom( javaType ) ) { return baseType; } if ( Calendar.class.isAssignableFrom( javaType ) ) { - return CalendarDateType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR_DATE ); } if ( java.util.Date.class.isAssignableFrom( javaType ) ) { - return TimestampType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.DATE ); } if ( Instant.class.isAssignableFrom( javaType ) ) { - return OffsetDateTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.INSTANT ); } if ( OffsetDateTime.class.isAssignableFrom( javaType ) ) { - return OffsetDateTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.OFFSET_DATE_TIME ); } if ( ZonedDateTime.class.isAssignableFrom( javaType ) ) { - return ZonedDateTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.ZONED_DATE_TIME ); } throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#DATE" ); } - public AllowableParameterType resolveTimeTemporalTypeVariant(Class javaType, AllowableParameterType baseType) { + public AllowableParameterType resolveTimeTemporalTypeVariant( + Class javaType, + AllowableParameterType baseType, + TypeConfiguration typeConfiguration) { if ( Calendar.class.isAssignableFrom( javaType ) ) { - return CalendarTimeType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.CALENDAR_TIME ); } if ( java.util.Date.class.isAssignableFrom( javaType ) ) { - return TimestampType.INSTANCE; + return typeConfiguration.getBasicTypeRegistry().resolve( StandardBasicTypes.TIME ); } throw new IllegalArgumentException( "Unsure how to handle given Java type [" + javaType.getName() + "] as TemporalType#TIME" ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingImpl.java b/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingImpl.java index ea6b98c90c..26b1cdd005 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingImpl.java @@ -20,6 +20,7 @@ import org.hibernate.query.spi.QueryParameterBindingTypeResolver; import org.hibernate.query.spi.QueryParameterBindingValidator; import org.hibernate.type.descriptor.java.CoercionException; import org.hibernate.type.descriptor.java.JavaType; +import org.hibernate.type.descriptor.java.TemporalJavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; /** @@ -232,15 +233,7 @@ public class QueryParameterBindingImpl implements QueryParameterBinding, J } bindValue( value ); - - if ( bindType != null ) { - bindType = (AllowableParameterType) BindingTypeHelper.INSTANCE.resolveDateTemporalTypeVariant( - bindType.getExpressableJavaTypeDescriptor().getJavaTypeClass(), - bindType - ); - } - - this.explicitTemporalPrecision = temporalTypePrecision; + setExplicitTemporalPrecision( temporalTypePrecision ); } @@ -291,12 +284,18 @@ public class QueryParameterBindingImpl implements QueryParameterBinding, J TemporalType temporalTypePrecision, TypeConfiguration typeConfiguration) { setBindValues( values ); + setExplicitTemporalPrecision( temporalTypePrecision ); + } - this.bindType = BindingTypeHelper.INSTANCE.resolveTemporalPrecision( - temporalTypePrecision, - bindType, - getTypeConfiguration() - ); + private void setExplicitTemporalPrecision(TemporalType temporalTypePrecision) { + // todo (6.0): what to do with converted attributes? + if ( bindType == null || bindType.getExpressableJavaTypeDescriptor() instanceof TemporalJavaTypeDescriptor ) { + this.bindType = BindingTypeHelper.INSTANCE.resolveTemporalPrecision( + temporalTypePrecision, + bindType, + getTypeConfiguration() + ); + } this.explicitTemporalPrecision = temporalTypePrecision; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java index 1878e31f6a..dbd6d7dc1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java @@ -39,8 +39,6 @@ import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.JdbcInsert; import org.hibernate.sql.exec.spi.JdbcParameterBindings; import org.hibernate.sql.results.internal.SqlSelectionImpl; -import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.UUIDCharType; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java index b1a1889873..c6b9dce525 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java @@ -83,7 +83,14 @@ public interface JdbcParameterBindings { (selectionIndex, jdbcValue, type) -> { addBinding( jdbcParameters.get( selectionIndex ), - new JdbcParameterBindingImpl( BindingTypeHelper.INSTANCE.resolveBindType( jdbcValue, type ), jdbcValue ) + new JdbcParameterBindingImpl( + BindingTypeHelper.INSTANCE.resolveBindType( + jdbcValue, + type, + session.getTypeConfiguration() + ), + jdbcValue + ) ); } , diff --git a/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java b/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java deleted file mode 100644 index 6c3bfc56bd..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.math.BigDecimal; - -import org.hibernate.type.descriptor.java.BigDecimalJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NumericJdbcType; - -/** - * A type that maps between a {@link java.sql.Types#NUMERIC NUMERIC} and {@link BigDecimal}. - * - * @author Gavin King - * @author Steve Ebersole - */ -public class BigDecimalType extends AbstractSingleColumnStandardBasicType { - public static final BigDecimalType INSTANCE = new BigDecimalType(); - - public BigDecimalType() { - super( NumericJdbcType.INSTANCE, BigDecimalJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "big_decimal"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/BigIntegerType.java b/hibernate-core/src/main/java/org/hibernate/type/BigIntegerType.java deleted file mode 100644 index d1cef8cb27..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/BigIntegerType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.math.BigInteger; - -import org.hibernate.type.descriptor.java.BigIntegerJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NumericJdbcType; - -/** - * A type that maps between a {@link java.sql.Types#NUMERIC NUMERIC} and {@link BigInteger}. - * - * @author Gavin King - * @author Steve Ebersole - */ -public class BigIntegerType - extends AbstractSingleColumnStandardBasicType { - - public static final BigIntegerType INSTANCE = new BigIntegerType(); - - public BigIntegerType() { - super( NumericJdbcType.INSTANCE, BigIntegerJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "big_integer"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/BinaryType.java b/hibernate-core/src/main/java/org/hibernate/type/BinaryType.java deleted file mode 100644 index 78f0399609..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/BinaryType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType; - -/** - * A type that maps between a {@link Types#VARBINARY VARBINARY} and {@code byte[]} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class BinaryType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - - public static final BinaryType INSTANCE = new BinaryType(); - - public String getName() { - return "binary"; - } - - public BinaryType() { - super( VarbinaryJdbcType.INSTANCE, PrimitiveByteArrayJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), "byte[]", byte[].class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/BlobType.java b/hibernate-core/src/main/java/org/hibernate/type/BlobType.java deleted file mode 100644 index 6ba1f296bc..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/BlobType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Blob; - -import org.hibernate.type.descriptor.java.BlobJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.BlobJdbcType; - -/** - * A type that maps between {@link java.sql.Types#BLOB BLOB} and {@link Blob} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class BlobType extends AbstractSingleColumnStandardBasicType { - public static final BlobType INSTANCE = new BlobType(); - - public BlobType() { - super( BlobJdbcType.DEFAULT, BlobJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "blob"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/BooleanType.java b/hibernate-core/src/main/java/org/hibernate/type/BooleanType.java deleted file mode 100644 index 642dea42e2..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/BooleanType.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.Incubating; -import org.hibernate.type.descriptor.java.BooleanJavaTypeDescriptor; -import org.hibernate.type.descriptor.java.JavaType; -import org.hibernate.type.descriptor.jdbc.BooleanJdbcType; -import org.hibernate.type.descriptor.jdbc.JdbcType; - -/** - * A type that maps between {@link Types#BOOLEAN BOOLEAN} and {@link Boolean} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class BooleanType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final BooleanType INSTANCE = new BooleanType(); - - public BooleanType() { - this( BooleanJdbcType.INSTANCE, BooleanJavaTypeDescriptor.INSTANCE ); - } - - protected BooleanType(JdbcType jdbcType, BooleanJavaTypeDescriptor javaTypeDescriptor) { - super( jdbcType, javaTypeDescriptor ); - } - - @Incubating - public BooleanType(JdbcType jdbcType, JavaType javaTypeDescriptor) { - super( jdbcType, javaTypeDescriptor ); - } - - @Override - public String getName() { - return "boolean"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), boolean.class.getName(), Boolean.class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ByteType.java b/hibernate-core/src/main/java/org/hibernate/type/ByteType.java deleted file mode 100644 index 51b4f676b4..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ByteType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.ByteJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TinyIntJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TINYINT TINYINT} and {@link Byte} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class ByteType - extends AbstractSingleColumnStandardBasicType { - - public static final ByteType INSTANCE = new ByteType(); - - public ByteType() { - super( TinyIntJdbcType.INSTANCE, ByteJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "byte"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] {getName(), byte.class.getName(), Byte.class.getName()}; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CalendarDateType.java b/hibernate-core/src/main/java/org/hibernate/type/CalendarDateType.java deleted file mode 100644 index be071d02e8..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CalendarDateType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Calendar; - -import org.hibernate.type.descriptor.java.CalendarDateJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.DateJdbcType; - -/** - * A type mapping {@link java.sql.Types#DATE DATE} and {@link Calendar} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class CalendarDateType - extends AbstractSingleColumnStandardBasicType { - public static final CalendarDateType INSTANCE = new CalendarDateType(); - - public CalendarDateType() { - super( DateJdbcType.INSTANCE, CalendarDateJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "calendar_date"; - } - - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CalendarTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/CalendarTimeType.java deleted file mode 100644 index baab165b77..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CalendarTimeType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Calendar; - -import org.hibernate.type.descriptor.java.CalendarTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimeJdbcType; - -/** - * A type mapping {@link java.sql.Types#TIME TIME} and {@link Calendar}. - *

- * For example, a Calendar attribute annotated with {@link jakarta.persistence.Temporal} and specifying - * {@link jakarta.persistence.TemporalType#TIME} - * - * @author Steve Ebersole - */ -public class CalendarTimeType - extends AbstractSingleColumnStandardBasicType { - public static final CalendarTimeType INSTANCE = new CalendarTimeType(); - - public CalendarTimeType() { - super( TimeJdbcType.INSTANCE, CalendarTimeJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "calendar_time"; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CalendarType.java b/hibernate-core/src/main/java/org/hibernate/type/CalendarType.java deleted file mode 100644 index ac274e6db7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CalendarType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Calendar; -import java.util.GregorianCalendar; - -import org.hibernate.type.descriptor.java.CalendarJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimestampJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link Calendar} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class CalendarType - extends AbstractSingleColumnStandardBasicType { - - public static final CalendarType INSTANCE = new CalendarType(); - - public CalendarType() { - super( TimestampJdbcType.INSTANCE, CalendarJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "calendar"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), Calendar.class.getName(), GregorianCalendar.class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharArrayType.java b/hibernate-core/src/main/java/org/hibernate/type/CharArrayType.java deleted file mode 100644 index fbed8cd308..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharArrayType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link Types#VARCHAR VARCHAR} and {@code char[]} - * - * @author Emmanuel Bernard - * @author Steve Ebersole - */ -public class CharArrayType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final CharArrayType INSTANCE = new CharArrayType(); - - public CharArrayType() { - super( VarcharJdbcType.INSTANCE, PrimitiveCharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "characters"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), "char[]", char[].class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayClobType.java b/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayClobType.java deleted file mode 100644 index c51d37c08f..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayClobType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.CharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.ClobJdbcType; - -/** - * A type that maps between {@link Types#CLOB CLOB} and {@link Character Character[]} - *

- * Essentially a {@link MaterializedClobType} but represented as a Character[] in Java rather than String. - * - * @author Emmanuel Bernard - * @author Steve Ebersole - */ -public class CharacterArrayClobType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final CharacterArrayClobType INSTANCE = new CharacterArrayClobType(); - - public CharacterArrayClobType() { - super( ClobJdbcType.DEFAULT, CharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - // todo name these annotation types for addition to the registry - return null; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayNClobType.java b/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayNClobType.java deleted file mode 100644 index 5cb14697a6..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayNClobType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.CharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NClobJdbcType; - -/** - * A type that maps between {@link Types#NCLOB NCLOB} and {@link Character Character[]} - *

- * Essentially a {@link MaterializedNClobType} but represented as a Character[] in Java rather than String. - * - * @author Emmanuel Bernard - * @author Steve Ebersole - */ -public class CharacterArrayNClobType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final CharacterArrayNClobType INSTANCE = new CharacterArrayNClobType(); - - public CharacterArrayNClobType() { - super( NClobJdbcType.DEFAULT, CharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - // todo name these annotation types for addition to the registry - return null; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayType.java b/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayType.java deleted file mode 100644 index e33117e0a8..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharacterArrayType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.CharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link Types#VARCHAR VARCHAR} and {@link Character Character[]} - * - * @author Emmanuel Bernard - * @author Steve Ebersole - */ -public class CharacterArrayType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final CharacterArrayType INSTANCE = new CharacterArrayType(); - - public CharacterArrayType() { - super( VarcharJdbcType.INSTANCE, CharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "wrapper-characters"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), Character[].class.getName(), "Character[]" }; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharacterNCharType.java b/hibernate-core/src/main/java/org/hibernate/type/CharacterNCharType.java deleted file mode 100644 index dcdc849947..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharacterNCharType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.CharacterJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NCharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#NCHAR NCHAR(1)} and {@link Character} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class CharacterNCharType - extends AbstractSingleColumnStandardBasicType { - - public static final CharacterNCharType INSTANCE = new CharacterNCharType(); - - public CharacterNCharType() { - super( NCharJdbcType.INSTANCE, CharacterJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "ncharacter"; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CharacterType.java b/hibernate-core/src/main/java/org/hibernate/type/CharacterType.java deleted file mode 100644 index 5efe943d84..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CharacterType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.CharacterJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.CharJdbcType; - -/** - * A type that maps between {@link Types#CHAR CHAR(1)} and {@link Character} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class CharacterType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - - public static final CharacterType INSTANCE = new CharacterType(); - - public CharacterType() { - super( CharJdbcType.INSTANCE, CharacterJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "character"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), char.class.getName(), Character.class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ClassType.java b/hibernate-core/src/main/java/org/hibernate/type/ClassType.java deleted file mode 100644 index 42f5bff8d4..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ClassType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; -import org.hibernate.type.descriptor.java.ClassJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and {@link Class} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class ClassType extends AbstractSingleColumnStandardBasicType { - public static final ClassType INSTANCE = new ClassType(); - - public ClassType() { - super( VarcharJdbcType.INSTANCE, ClassJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "class"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ClobType.java b/hibernate-core/src/main/java/org/hibernate/type/ClobType.java deleted file mode 100644 index f2d0d6b7f3..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ClobType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Clob; -import java.sql.Types; - -import org.hibernate.type.descriptor.java.ClobJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.ClobJdbcType; - -/** - * A type that maps between {@link Types#CLOB CLOB} and {@link Clob} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class ClobType extends AbstractSingleColumnStandardBasicType implements AdjustableBasicType { - public static final ClobType INSTANCE = new ClobType(); - - public ClobType() { - super( ClobJdbcType.DEFAULT, ClobJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "clob"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/CurrencyType.java b/hibernate-core/src/main/java/org/hibernate/type/CurrencyType.java deleted file mode 100644 index 724c006bca..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/CurrencyType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Currency; - -import org.hibernate.type.descriptor.java.CurrencyJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and {@link Currency} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class CurrencyType - extends AbstractSingleColumnStandardBasicType { - - public static final CurrencyType INSTANCE = new CurrencyType(); - - public CurrencyType() { - super( VarcharJdbcType.INSTANCE, CurrencyJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "currency"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/DateType.java b/hibernate-core/src/main/java/org/hibernate/type/DateType.java deleted file mode 100644 index fa82c84b7d..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/DateType.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Date; - -import org.hibernate.type.descriptor.java.JdbcDateJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.DateJdbcType; - -/** - * A type that maps between {@link java.sql.Types#DATE DATE} and {@link java.sql.Date} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class DateType - extends AbstractSingleColumnStandardBasicType { - - public static final DateType INSTANCE = new DateType(); - - public DateType() { - super( DateJdbcType.INSTANCE, JdbcDateJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "date"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { - getName(), - java.sql.Date.class.getName() - }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java b/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java deleted file mode 100644 index fcb23fda2b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/DoubleType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.DoubleJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.DoubleJdbcType; - -/** - * A type that maps between {@link java.sql.Types#DOUBLE DOUBLE} and {@link Double} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class DoubleType - extends AbstractSingleColumnStandardBasicType { - public static final DoubleType INSTANCE = new DoubleType(); - - public DoubleType() { - super( DoubleJdbcType.INSTANCE, DoubleJavaTypeDescriptor.INSTANCE ); - } - @Override - public String getName() { - return "double"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), double.class.getName(), Double.class.getName() }; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/DurationType.java b/hibernate-core/src/main/java/org/hibernate/type/DurationType.java deleted file mode 100644 index 50c8a73c48..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/DurationType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.Duration; - -import org.hibernate.type.descriptor.java.DurationJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NumericJdbcType; - -/** - * @author Steve Ebersole - */ -public class DurationType - extends AbstractSingleColumnStandardBasicType { - /** - * Singleton access - */ - public static final DurationType INSTANCE = new DurationType(); - - public DurationType() { - super( NumericJdbcType.INSTANCE, DurationJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return Duration.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/FloatType.java b/hibernate-core/src/main/java/org/hibernate/type/FloatType.java deleted file mode 100644 index 634a1a69fa..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/FloatType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.FloatTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.FloatJdbcType; - -/** - * A type that maps between {@link java.sql.Types#FLOAT FLOAT} and {@link Float} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class FloatType extends AbstractSingleColumnStandardBasicType { - public static final FloatType INSTANCE = new FloatType(); - - - public FloatType() { - super( FloatJdbcType.INSTANCE, FloatTypeDescriptor.INSTANCE ); - } - @Override - public String getName() { - return "float"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), float.class.getName(), Float.class.getName() }; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ImageType.java b/hibernate-core/src/main/java/org/hibernate/type/ImageType.java deleted file mode 100644 index 59c1bb08af..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ImageType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; -import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.LongVarbinaryJdbcType; - -/** - * A type that maps between {@link java.sql.Types#LONGVARBINARY LONGVARBINARY} and {@code byte[]} - * - * @author Gavin King - * @author Emmanuel Bernard - * @author Gail Badner - * @author Steve Ebersole - */ -public class ImageType extends AbstractSingleColumnStandardBasicType { - public static final ImageType INSTANCE = new ImageType(); - - public ImageType() { - super( LongVarbinaryJdbcType.INSTANCE, PrimitiveByteArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "image"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/InstantType.java b/hibernate-core/src/main/java/org/hibernate/type/InstantType.java deleted file mode 100644 index 3815293dda..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/InstantType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.Instant; - -import org.hibernate.type.descriptor.java.InstantJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimestampJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link java.time.LocalDateTime}. - * - * @author Steve Ebersole - */ -public class InstantType - extends AbstractSingleColumnStandardBasicType { - /** - * Singleton access - */ - public static final InstantType INSTANCE = new InstantType(); - - public InstantType() { - super( TimestampJdbcType.INSTANCE, InstantJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "instant"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/IntegerType.java b/hibernate-core/src/main/java/org/hibernate/type/IntegerType.java deleted file mode 100644 index e5e44fd06a..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/IntegerType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.IntegerJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.IntegerJdbcType; - -/** - * A type that maps between {@link java.sql.Types#INTEGER INTEGER} and @link Integer} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class IntegerType extends AbstractSingleColumnStandardBasicType { - - public static final IntegerType INSTANCE = new IntegerType(); - - public IntegerType() { - super( IntegerJdbcType.INSTANCE, IntegerJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "integer"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] {getName(), int.class.getName(), Integer.class.getName()}; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/LocalDateTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/LocalDateTimeType.java deleted file mode 100644 index 49c3423ddd..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/LocalDateTimeType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.LocalDateTime; - -import org.hibernate.type.descriptor.java.LocalDateTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimestampJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link LocalDateTime}. - * - * @author Steve Ebersole - */ -public class LocalDateTimeType - extends AbstractSingleColumnStandardBasicType { - /** - * Singleton access - */ - public static final LocalDateTimeType INSTANCE = new LocalDateTimeType(); - - public LocalDateTimeType() { - super( TimestampJdbcType.INSTANCE, LocalDateTimeJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return LocalDateTime.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/LocalDateType.java b/hibernate-core/src/main/java/org/hibernate/type/LocalDateType.java deleted file mode 100644 index 55664d6633..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/LocalDateType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.LocalDate; - -import org.hibernate.type.descriptor.java.LocalDateJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.DateJdbcType; - -/** - * @author Steve Ebersole - */ -public class LocalDateType - extends AbstractSingleColumnStandardBasicType { - - /** - * Singleton access - */ - public static final LocalDateType INSTANCE = new LocalDateType(); - - public LocalDateType() { - super( DateJdbcType.INSTANCE, LocalDateJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return LocalDate.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/LocalTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/LocalTimeType.java deleted file mode 100644 index beaccef7ce..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/LocalTimeType.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.LocalTime; - -import org.hibernate.type.descriptor.java.LocalTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimeJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TIMESTAMP TIMESTAMP} and {@link java.time.LocalDateTime}. - * - * @author Steve Ebersole - */ -public class LocalTimeType - extends AbstractSingleColumnStandardBasicType { - /** - * Singleton access - */ - public static final LocalTimeType INSTANCE = new LocalTimeType(); - - public LocalTimeType() { - super( TimeJdbcType.INSTANCE, LocalTimeJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return LocalTime.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/LocaleType.java b/hibernate-core/src/main/java/org/hibernate/type/LocaleType.java deleted file mode 100644 index c918508cfa..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/LocaleType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.Locale; - -import org.hibernate.type.descriptor.java.LocaleJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and @link Locale} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class LocaleType extends AbstractSingleColumnStandardBasicType { - - public static final LocaleType INSTANCE = new LocaleType(); - - public LocaleType() { - super( VarcharJdbcType.INSTANCE, LocaleJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "locale"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/LongType.java b/hibernate-core/src/main/java/org/hibernate/type/LongType.java deleted file mode 100644 index 10daaa785b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/LongType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.LongJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.BigIntJdbcType; - -/** - * A type that maps between {@link java.sql.Types#BIGINT BIGINT} and {@link Long} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class LongType - extends AbstractSingleColumnStandardBasicType { - - public static final LongType INSTANCE = new LongType(); - - public LongType() { - super( BigIntJdbcType.INSTANCE, LongJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "long"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), long.class.getName(), Long.class.getName() }; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/MaterializedBlobType.java b/hibernate-core/src/main/java/org/hibernate/type/MaterializedBlobType.java deleted file mode 100644 index 8f2178e3dc..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/MaterializedBlobType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; -import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.BlobJdbcType; - -/** - * A type that maps between {@link java.sql.Types#BLOB BLOB} and {@code byte[]} - * - * @author Gavin King - * @author Emmanuel Bernard - * @author Gail Badner - * @author Steve Ebersole - */ -public class MaterializedBlobType extends AbstractSingleColumnStandardBasicType { - public static final MaterializedBlobType INSTANCE = new MaterializedBlobType(); - - public MaterializedBlobType() { - super( BlobJdbcType.DEFAULT, PrimitiveByteArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "materialized_blob"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/MaterializedClobType.java b/hibernate-core/src/main/java/org/hibernate/type/MaterializedClobType.java deleted file mode 100644 index 44ffb8bf87..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/MaterializedClobType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.ClobJdbcType; - -/** - * A type that maps between {@link Types#CLOB CLOB} and {@link String} - * - * @author Gavin King - * @author Gail Badner - * @author Steve Ebersole - */ -public class MaterializedClobType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final MaterializedClobType INSTANCE = new MaterializedClobType(); - - public MaterializedClobType() { - super( ClobJdbcType.DEFAULT, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "materialized_clob"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/MaterializedNClobType.java b/hibernate-core/src/main/java/org/hibernate/type/MaterializedNClobType.java deleted file mode 100644 index b021c19790..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/MaterializedNClobType.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NClobJdbcType; - -/** - * A type that maps between {@link java.sql.Types#CLOB CLOB} and {@link String} - * - * @author Gavin King - * @author Gail Badner - * @author Steve Ebersole - */ -public class MaterializedNClobType extends AbstractSingleColumnStandardBasicType { - public static final MaterializedNClobType INSTANCE = new MaterializedNClobType(); - - public MaterializedNClobType() { - super( NClobJdbcType.DEFAULT, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "materialized_nclob"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/NClobType.java b/hibernate-core/src/main/java/org/hibernate/type/NClobType.java deleted file mode 100644 index 601bec7870..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/NClobType.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.NClob; - -import org.hibernate.type.descriptor.java.NClobJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NClobJdbcType; - -/** - * A type that maps between {@link java.sql.Types#NCLOB NCLOB} and {@link NClob} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class NClobType extends AbstractSingleColumnStandardBasicType { - public static final NClobType INSTANCE = new NClobType(); - - public NClobType() { - super( NClobJdbcType.DEFAULT, NClobJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "nclob"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/NTextType.java b/hibernate-core/src/main/java/org/hibernate/type/NTextType.java deleted file mode 100644 index ec0df29357..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/NTextType.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.LongNVarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#LONGNVARCHAR LONGNVARCHAR} and {@link String} - * - * @author Gavin King, - * @author Bertrand Renuart - * @author Steve Ebersole - */ -public class NTextType extends AbstractSingleColumnStandardBasicType { - public static final NTextType INSTANCE = new NTextType(); - - public NTextType() { - super( LongNVarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "ntext"; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/NumericBooleanType.java b/hibernate-core/src/main/java/org/hibernate/type/NumericBooleanType.java deleted file mode 100644 index 0c62383b78..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/NumericBooleanType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; -import org.hibernate.type.descriptor.java.BooleanJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.IntegerJdbcType; - -/** - * A type that maps between {@link java.sql.Types#INTEGER INTEGER} and {@link Boolean} (using 1 and 0) - * - * @author Steve Ebersole - */ -public class NumericBooleanType - extends AbstractSingleColumnStandardBasicType - implements ConvertedBasicType { - - public static final NumericBooleanType INSTANCE = new NumericBooleanType(); - - public NumericBooleanType() { - super( IntegerJdbcType.INSTANCE, BooleanJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "numeric_boolean"; - } - - @Override - public BasicValueConverter getValueConverter() { - return NumericBooleanConverter.INSTANCE; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/OffsetDateTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/OffsetDateTimeType.java deleted file mode 100644 index b28c680504..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/OffsetDateTimeType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.OffsetDateTime; - -import org.hibernate.type.descriptor.java.OffsetDateTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimestampWithTimeZoneJdbcType; - -/** - * @author Steve Ebersole - */ -public class OffsetDateTimeType - extends AbstractSingleColumnStandardBasicType { - - /** - * Singleton access - */ - public static final OffsetDateTimeType INSTANCE = new OffsetDateTimeType(); - - public OffsetDateTimeType() { - super( TimestampWithTimeZoneJdbcType.INSTANCE, OffsetDateTimeJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return OffsetDateTime.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/OffsetTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/OffsetTimeType.java deleted file mode 100644 index 266406a57a..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/OffsetTimeType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.OffsetTime; - -import org.hibernate.type.descriptor.java.OffsetTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimeJdbcType; - -/** - * @author Steve Ebersole - */ -public class OffsetTimeType - extends AbstractSingleColumnStandardBasicType { - - /** - * Singleton access - */ - public static final OffsetTimeType INSTANCE = new OffsetTimeType(); - - public OffsetTimeType() { - super( TimeJdbcType.INSTANCE, OffsetTimeJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return OffsetTime.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayClobType.java b/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayClobType.java deleted file mode 100644 index 41f1cb2f78..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayClobType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.ClobJdbcType; - -/** - * Map a char[] to a Clob - * - * @author Emmanuel Bernard - */ -public class PrimitiveCharacterArrayClobType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final CharacterArrayClobType INSTANCE = new CharacterArrayClobType(); - - public PrimitiveCharacterArrayClobType() { - super( ClobJdbcType.DEFAULT, PrimitiveCharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - // todo name these annotation types for addition to the registry - return null; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayNClobType.java b/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayNClobType.java deleted file mode 100644 index 8e650e12f7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/PrimitiveCharacterArrayNClobType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.PrimitiveCharacterArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NClobJdbcType; - -/** - * Map a char[] to a NClob - * - * @author Emmanuel Bernard - */ -public class PrimitiveCharacterArrayNClobType extends AbstractSingleColumnStandardBasicType { - public static final CharacterArrayNClobType INSTANCE = new CharacterArrayNClobType(); - - public PrimitiveCharacterArrayNClobType() { - super( NClobJdbcType.DEFAULT, PrimitiveCharacterArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - // todo name these annotation types for addition to the registry - return null; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ShortType.java b/hibernate-core/src/main/java/org/hibernate/type/ShortType.java deleted file mode 100644 index f8bc4009f8..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ShortType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.ShortJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.SmallIntJdbcType; - -/** - * A type that maps between {@link java.sql.Types#SMALLINT SMALLINT} and {@link Short} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class ShortType - extends AbstractSingleColumnStandardBasicType { - - public static final ShortType INSTANCE = new ShortType(); - - private static final Short ZERO = (short) 0; - - public ShortType() { - super( SmallIntJdbcType.INSTANCE, ShortJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "short"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] {getName(), short.class.getName(), Short.class.getName()}; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/StandardBasicTypes.java b/hibernate-core/src/main/java/org/hibernate/type/StandardBasicTypes.java index b99debfb02..f914657b08 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/StandardBasicTypes.java +++ b/hibernate-core/src/main/java/org/hibernate/type/StandardBasicTypes.java @@ -399,6 +399,7 @@ public final class StandardBasicTypes { /** * The standard Hibernate type for mapping {@link OffsetDateTime} to JDBC {@link java.sql.Types#TIMESTAMP_WITH_TIMEZONE TIMESTAMP_WITH_TIMEZONE}. + * This maps to {@link org.hibernate.TimeZoneStorageStrategy#NATIVE}. */ public static final BasicTypeReference OFFSET_DATE_TIME_WITH_TIMEZONE = new BasicTypeReference<>( "OffsetDateTimeWithTimezone", @@ -407,6 +408,7 @@ public final class StandardBasicTypes { ); /** * The standard Hibernate type for mapping {@link OffsetDateTime} to JDBC {@link java.sql.Types#TIMESTAMP TIMESTAMP}. + * This maps to {@link org.hibernate.TimeZoneStorageStrategy#NORMALIZE}. */ public static final BasicTypeReference OFFSET_DATE_TIME_WITHOUT_TIMEZONE = new BasicTypeReference<>( "OffsetDateTimeWithoutTimezone", @@ -436,6 +438,7 @@ public final class StandardBasicTypes { /** * The standard Hibernate type for mapping {@link ZonedDateTime} to JDBC {@link java.sql.Types#TIMESTAMP_WITH_TIMEZONE TIMESTAMP_WITH_TIMEZONE}. + * This maps to {@link org.hibernate.TimeZoneStorageStrategy#NATIVE}. */ public static final BasicTypeReference ZONED_DATE_TIME_WITH_TIMEZONE = new BasicTypeReference<>( "ZonedDateTimeWithTimezone", @@ -445,6 +448,7 @@ public final class StandardBasicTypes { /** * The standard Hibernate type for mapping {@link ZonedDateTime} to JDBC {@link java.sql.Types#TIMESTAMP TIMESTAMP}. + * This maps to {@link org.hibernate.TimeZoneStorageStrategy#NORMALIZE}. */ public static final BasicTypeReference ZONED_DATE_TIME_WITHOUT_TIMEZONE = new BasicTypeReference<>( "ZonedDateTimeWithoutTimezone", @@ -721,21 +725,21 @@ public final class StandardBasicTypes { NUMERIC_BOOLEAN, "org.hibernate.type.NumericBooleanType", basicTypeRegistry, - "numeric_boolean" + "numeric_boolean", NumericBooleanConverter.class.getName() ); handle( TRUE_FALSE, "org.hibernate.type.TrueFalseType", basicTypeRegistry, - "true_false" + "true_false", TrueFalseConverter.class.getName() ); handle( YES_NO, "org.hibernate.type.YesNoType", basicTypeRegistry, - "yes_no" + "yes_no", YesNoConverter.class.getName() ); @@ -1053,7 +1057,7 @@ public final class StandardBasicTypes { CALENDAR_TIME, "org.hibernate.type.CalendarTimeType", basicTypeRegistry, - "calendar_date" + "calendar_time" ); handle( diff --git a/hibernate-core/src/main/java/org/hibernate/type/StringNVarcharType.java b/hibernate-core/src/main/java/org/hibernate/type/StringNVarcharType.java deleted file mode 100644 index 45b528a132..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/StringNVarcharType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.NVarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and {@link String} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class StringNVarcharType - extends AbstractSingleColumnStandardBasicType { - - public static final StringNVarcharType INSTANCE = new StringNVarcharType(); - - public StringNVarcharType() { - super( NVarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "nstring"; - } - - @Override - protected boolean registerUnderJavaType() { - return false; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/StringType.java b/hibernate-core/src/main/java/org/hibernate/type/StringType.java deleted file mode 100644 index 6ce9f1fb54..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/StringType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link Types#VARCHAR VARCHAR} and {@link String} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class StringType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - - public static final StringType INSTANCE = new StringType(); - - public StringType() { - super( VarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "string"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/TextType.java b/hibernate-core/src/main/java/org/hibernate/type/TextType.java deleted file mode 100644 index 983b681771..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/TextType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.StringJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.LongVarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#LONGVARCHAR LONGVARCHAR} and {@link String} - * - * @author Gavin King, - * @author Bertrand Renuart - * @author Steve Ebersole - */ -public class TextType - extends AbstractSingleColumnStandardBasicType - implements AdjustableBasicType { - public static final TextType INSTANCE = new TextType(); - - public TextType() { - super( LongVarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "text"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/TimeType.java b/hibernate-core/src/main/java/org/hibernate/type/TimeType.java deleted file mode 100644 index 596a8f2adf..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/TimeType.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Time; -import java.util.Date; - -import org.hibernate.type.descriptor.java.JdbcTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimeJdbcType; - -/** - * A type that maps between {@link java.sql.Types#TIME TIME} and {@link Time} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class TimeType - extends AbstractSingleColumnStandardBasicType { - - public static final TimeType INSTANCE = new TimeType(); - - public TimeType() { - super( TimeJdbcType.INSTANCE, JdbcTimeJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "time"; - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { - getName(), - Time.class.getName() - }; - } - - // @Override -// protected boolean registerUnderJavaType() { -// return true; -// } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/TimeZoneType.java b/hibernate-core/src/main/java/org/hibernate/type/TimeZoneType.java deleted file mode 100644 index a64a28f4d9..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/TimeZoneType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.TimeZone; - -import org.hibernate.type.descriptor.java.TimeZoneJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type mapping {@link java.sql.Types#VARCHAR VARCHAR} and {@link TimeZone} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class TimeZoneType - extends AbstractSingleColumnStandardBasicType { - - public static final TimeZoneType INSTANCE = new TimeZoneType(); - - public TimeZoneType() { - super( VarcharJdbcType.INSTANCE, TimeZoneJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "timezone"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/TrueFalseType.java b/hibernate-core/src/main/java/org/hibernate/type/TrueFalseType.java deleted file mode 100644 index 60d1a75b59..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/TrueFalseType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; -import org.hibernate.type.descriptor.java.BooleanJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.CharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#CHAR CHAR(1)} and {@link Boolean} (using 'T' and 'F') - * - * @author Gavin King - * @author Steve Ebersole - */ -public class TrueFalseType - extends AbstractSingleColumnStandardBasicType - implements ConvertedBasicType { - - public static final TrueFalseType INSTANCE = new TrueFalseType(); - - public TrueFalseType() { - super( CharJdbcType.INSTANCE, new BooleanJavaTypeDescriptor( 'T', 'F' ) ); - } - - @Override - public String getName() { - return "true_false"; - } - - @Override - public BasicValueConverter getValueConverter() { - return TrueFalseConverter.INSTANCE; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/UUIDBinaryType.java b/hibernate-core/src/main/java/org/hibernate/type/UUIDBinaryType.java deleted file mode 100644 index 108797e3bb..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/UUIDBinaryType.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.UUID; - -import org.hibernate.dialect.Dialect; -import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.BinaryJdbcType; -import org.hibernate.type.descriptor.jdbc.JdbcType; - -/** - * A type mapping {@link java.sql.Types#BINARY} and {@link UUID} - * - * @author Steve Ebersole - */ -public class UUIDBinaryType extends AbstractSingleColumnStandardBasicType { - public static final UUIDBinaryType INSTANCE = new UUIDBinaryType(); - - public UUIDBinaryType() { - super( BinaryJdbcType.INSTANCE, new UUIDJavaTypeDescriptor() { - @Override - public long getDefaultSqlLength( - Dialect dialect, - JdbcType jdbcType) { - return 16; - } - } ); - } - - public String getName() { - return "uuid-binary"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/UUIDCharType.java b/hibernate-core/src/main/java/org/hibernate/type/UUIDCharType.java deleted file mode 100644 index 1108176446..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/UUIDCharType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.util.UUID; - -import org.hibernate.dialect.Dialect; -import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.JdbcType; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type mapping {@link java.sql.Types#CHAR} (or {@link java.sql.Types#VARCHAR}) and {@link UUID} - * - * @author Steve Ebersole - */ -public class UUIDCharType extends AbstractSingleColumnStandardBasicType { - public static final UUIDCharType INSTANCE = new UUIDCharType(); - - public UUIDCharType() { - super( VarcharJdbcType.INSTANCE, new UUIDJavaTypeDescriptor() { - @Override - public long getDefaultSqlLength( - Dialect dialect, - JdbcType jdbcType) { - return 36; - } - } ); - } - - public String getName() { - return "uuid-char"; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/UrlType.java b/hibernate-core/src/main/java/org/hibernate/type/UrlType.java deleted file mode 100644 index e8319b928c..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/UrlType.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.net.URL; - -import org.hibernate.type.descriptor.java.UrlJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#VARCHAR VARCHAR} and {@link URL} - * - * @author Steve Ebersole - */ -public class UrlType extends AbstractSingleColumnStandardBasicType { - public static final UrlType INSTANCE = new UrlType(); - - public UrlType() { - super( VarcharJdbcType.INSTANCE, UrlJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return "url"; - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/WrappedMaterializedBlobType.java b/hibernate-core/src/main/java/org/hibernate/type/WrappedMaterializedBlobType.java deleted file mode 100644 index ef28c2aac3..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/WrappedMaterializedBlobType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; -import org.hibernate.type.descriptor.java.ByteArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.BlobJdbcType; - -/** - * A type that maps JDBC {@link java.sql.Types#BLOB BLOB} and {@code Byte[]}. - * A type that maps an SQL BLOB to Java Byte[]. - * - * @author Strong Liu - */ -public class WrappedMaterializedBlobType extends AbstractSingleColumnStandardBasicType { - public static final WrappedMaterializedBlobType INSTANCE = new WrappedMaterializedBlobType(); - - public WrappedMaterializedBlobType() { - super( BlobJdbcType.DEFAULT, ByteArrayJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - // todo name these annotation types for addition to the registry - return null; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/WrapperBinaryType.java b/hibernate-core/src/main/java/org/hibernate/type/WrapperBinaryType.java deleted file mode 100644 index 07b6839598..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/WrapperBinaryType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.sql.Types; - -import org.hibernate.type.descriptor.java.ByteArrayJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType; - -/** - * A type mapping {@link Types#VARBINARY VARBINARY} and {@link Byte Byte[]} - * - * @author Emmanuel Bernard - * @author Steve Ebersole - */ -public class WrapperBinaryType extends AbstractSingleColumnStandardBasicType implements AdjustableBasicType { - public static final WrapperBinaryType INSTANCE = new WrapperBinaryType(); - - public WrapperBinaryType() { - super( VarbinaryJdbcType.INSTANCE, ByteArrayJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String[] getRegistrationKeys() { - return new String[] { getName(), "Byte[]", Byte[].class.getName() }; - } - - public String getName() { - //TODO find a decent name before documenting - return "wrapper-binary"; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/YesNoType.java b/hibernate-core/src/main/java/org/hibernate/type/YesNoType.java deleted file mode 100644 index 4b36163962..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/YesNoType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; -import org.hibernate.type.descriptor.java.BooleanJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.CharJdbcType; - -/** - * A type that maps between {@link java.sql.Types#CHAR CHAR(1)} and {@link Boolean} (using 'Y' and 'N') - * - * @author Gavin King - * @author Steve Ebersole - */ -public class YesNoType - extends AbstractSingleColumnStandardBasicType - implements ConvertedBasicType { - - public static final YesNoType INSTANCE = new YesNoType(); - - public YesNoType() { - super( CharJdbcType.INSTANCE, BooleanJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return "yes_no"; - } - - @Override - public BasicValueConverter getValueConverter() { - return YesNoConverter.INSTANCE; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ZoneOffsetType.java b/hibernate-core/src/main/java/org/hibernate/type/ZoneOffsetType.java deleted file mode 100644 index 27c973d3be..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ZoneOffsetType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import org.hibernate.type.descriptor.java.ZoneOffsetJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.VarcharJdbcType; - -import java.time.ZoneOffset; - -/** - * A type mapping {@link java.sql.Types#VARCHAR VARCHAR} and {@link ZoneOffset} - * - * @author Gavin King - * @author Steve Ebersole - */ -public class ZoneOffsetType - extends AbstractSingleColumnStandardBasicType { - - public static final ZoneOffsetType INSTANCE = new ZoneOffsetType(); - - public ZoneOffsetType() { - super( VarcharJdbcType.INSTANCE, ZoneOffsetJavaTypeDescriptor.INSTANCE ); - } - - public String getName() { - return ZoneOffset.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } - -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/ZonedDateTimeType.java b/hibernate-core/src/main/java/org/hibernate/type/ZonedDateTimeType.java deleted file mode 100644 index 306b3c3917..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/type/ZonedDateTimeType.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.type; - -import java.time.ZonedDateTime; - -import org.hibernate.type.descriptor.java.ZonedDateTimeJavaTypeDescriptor; -import org.hibernate.type.descriptor.jdbc.TimestampWithTimeZoneJdbcType; - -/** - * @author Steve Ebersole - */ -public class ZonedDateTimeType - extends AbstractSingleColumnStandardBasicType { - - /** - * Singleton access - */ - public static final ZonedDateTimeType INSTANCE = new ZonedDateTimeType(); - - public ZonedDateTimeType() { - super( TimestampWithTimeZoneJdbcType.INSTANCE, ZonedDateTimeJavaTypeDescriptor.INSTANCE ); - } - - @Override - public String getName() { - return ZonedDateTime.class.getSimpleName(); - } - - @Override - protected boolean registerUnderJavaType() { - return true; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/InstantJavaTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/InstantJavaTypeDescriptor.java index 30caeb0dd1..724c8fad1c 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/InstantJavaTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/InstantJavaTypeDescriptor.java @@ -50,9 +50,8 @@ public class InstantJavaTypeDescriptor extends AbstractTemporalJavaTypeDescripto @Override protected TemporalJavaTypeDescriptor forDatePrecision(TypeConfiguration typeConfiguration) { - // todo (6.0) : resolve against the type registry instead? //noinspection unchecked - return (TemporalJavaTypeDescriptor) JdbcDateJavaTypeDescriptor.INSTANCE; + return (TemporalJavaTypeDescriptor) this; } @Override @@ -64,7 +63,7 @@ public class InstantJavaTypeDescriptor extends AbstractTemporalJavaTypeDescripto @Override protected TemporalJavaTypeDescriptor forTimePrecision(TypeConfiguration typeConfiguration) { //noinspection unchecked - return (TemporalJavaTypeDescriptor) JdbcTimeJavaTypeDescriptor.INSTANCE; + return (TemporalJavaTypeDescriptor) this; } @Override @@ -118,11 +117,11 @@ public class InstantJavaTypeDescriptor extends AbstractTemporalJavaTypeDescripto } if ( java.sql.Date.class.isAssignableFrom( type ) ) { - return (X) java.sql.Date.from( instant ); + return (X) new java.sql.Date( instant.toEpochMilli() ); } if ( java.sql.Time.class.isAssignableFrom( type ) ) { - return (X) java.sql.Time.from( instant ); + return (X) new java.sql.Time( instant.toEpochMilli() ); } if ( Date.class.isAssignableFrom( type ) ) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/lob/ImageTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/lob/ImageTest.java index ff9d3bdeb1..926db1e92f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/lob/ImageTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/lob/ImageTest.java @@ -20,7 +20,7 @@ import junit.framework.AssertionFailedError; /** * Tests eager materialization and mutation of data mapped by - * {@link org.hibernate.type.ImageType}. + * {@link org.hibernate.type.StandardBasicTypes#IMAGE}. * * @author Gail Badner */ diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/SubselectTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/SubselectTest.java index a77aa56682..f40dba6bef 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/SubselectTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/subselect/SubselectTest.java @@ -15,7 +15,6 @@ import org.hibernate.Transaction; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; /** * @author Sharath Reddy diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/function/AnsiTrimEmulationFunctionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/function/AnsiTrimEmulationFunctionTest.java index 38df4ce854..d8512f904b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/function/AnsiTrimEmulationFunctionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dialect/function/AnsiTrimEmulationFunctionTest.java @@ -17,7 +17,6 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.JdbcMappingContainer; import org.hibernate.query.TrimSpec; -import org.hibernate.query.spi.QueryEngine; import org.hibernate.sql.ast.SqlAstTranslator; import org.hibernate.sql.ast.spi.SqlAppender; import org.hibernate.sql.ast.spi.StandardSqlAstTranslator; @@ -26,7 +25,9 @@ import org.hibernate.sql.ast.tree.expression.QueryLiteral; import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression; import org.hibernate.sql.ast.tree.expression.TrimSpecification; import org.hibernate.sql.exec.spi.JdbcOperation; -import org.hibernate.type.CharacterType; +import org.hibernate.type.descriptor.java.CharacterJavaTypeDescriptor; +import org.hibernate.type.descriptor.jdbc.CharJdbcType; +import org.hibernate.type.internal.BasicTypeImpl; import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.testing.orm.junit.FailureExpected; @@ -129,7 +130,7 @@ public class AnsiTrimEmulationFunctionTest { ); List sqlAstArguments = new ArrayList<>(); sqlAstArguments.add( new TrimSpecification( trimSpec ) ); - sqlAstArguments.add( new QueryLiteral<>( trimCharacter, new CharacterType() ) ); + sqlAstArguments.add( new QueryLiteral<>( trimCharacter, new BasicTypeImpl<>( CharacterJavaTypeDescriptor.INSTANCE, CharJdbcType.INSTANCE ) ) ); sqlAstArguments.add( new SelfRenderingExpression() { @Override public void renderToSql( 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 78ae190bf7..49e98b8211 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 @@ -17,7 +17,6 @@ import org.hibernate.HibernateException; import org.hibernate.annotations.CustomType; import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.LongType; import org.hibernate.usertype.UserType; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/table/Db2GenerationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/table/Db2GenerationTest.java index 85db66f5a0..a2d1f8895b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/table/Db2GenerationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idgen/enhanced/table/Db2GenerationTest.java @@ -17,7 +17,6 @@ import org.hibernate.dialect.DB2Dialect; import org.hibernate.id.MultipleHiLoPerTableGenerator; import org.hibernate.id.enhanced.TableGenerator; import org.hibernate.mapping.Table; -import org.hibernate.type.IntegerType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/BlobLocatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/BlobLocatorTest.java index 6e47658131..81efdc374c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/BlobLocatorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/BlobLocatorTest.java @@ -25,7 +25,7 @@ import static org.junit.Assert.assertNotNull; /** * Tests lazy materialization of data mapped by - * {@link org.hibernate.type.BlobType}, as well as bounded and unbounded + * {@link org.hibernate.type.StandardBasicTypes#BLOB}, as well as bounded and unbounded * materialization and mutation. * * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/ClobLocatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/ClobLocatorTest.java index e5830d9b0b..8fceeb31ad 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/ClobLocatorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/ClobLocatorTest.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertNotNull; /** * Tests lazy materialization of data mapped by - * {@link org.hibernate.type.ClobType} as well as bounded and unbounded + * {@link org.hibernate.type.StandardBasicTypes#CLOB} as well as bounded and unbounded * materialization and mutation. * * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/LobHolder.java b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/LobHolder.java index 3b8d84c694..44d468d2f8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/lob/LobHolder.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/lob/LobHolder.java @@ -13,11 +13,11 @@ import java.sql.Clob; *

* {@link #clobLocator} is used to hold CLOB data that is materialized lazily * via a JDBC CLOB locator; it is mapped via the - * {@link org.hibernate.type.ClobType} + * {@link org.hibernate.type.StandardBasicTypes#CLOB} *

* {@link #blobLocator} is used to hold BLOB data that is materialized lazily * via a JDBC BLOB locator; it is mapped via the - * {@link org.hibernate.type.BlobType} + * {@link org.hibernate.type.StandardBasicTypes#BLOB} * * * @author Steve Ebersole diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/onetoone/link/OneToOneLinkTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/onetoone/link/OneToOneLinkTest.java index 3c848ea0d3..45558fd9f7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/onetoone/link/OneToOneLinkTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/onetoone/link/OneToOneLinkTest.java @@ -10,7 +10,6 @@ import java.util.Date; import org.hibernate.Hibernate; import org.hibernate.dialect.OracleDialect; -import org.hibernate.type.DateType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.orm.junit.DialectFeatureChecks; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/MySQLStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/MySQLStoredProcedureTest.java index 538acb1580..8227231700 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/MySQLStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/MySQLStoredProcedureTest.java @@ -23,7 +23,7 @@ import org.hibernate.procedure.ProcedureCall; import org.hibernate.query.procedure.ProcedureParameter; import org.hibernate.result.Output; import org.hibernate.result.ResultSetOutput; -import org.hibernate.type.StringType; +import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; @@ -353,7 +353,7 @@ public class MySQLStoredProcedureTest { scope.inTransaction( entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ).enablePassingNulls( true ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ).enablePassingNulls( true ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( 1, null ); @@ -365,7 +365,7 @@ public class MySQLStoredProcedureTest { scope.inTransaction( entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ).enablePassingNulls( true ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ).enablePassingNulls( true ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( 1, "test" ); @@ -382,7 +382,7 @@ public class MySQLStoredProcedureTest { scope.inTransaction( entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( 1, null ); @@ -400,7 +400,7 @@ public class MySQLStoredProcedureTest { try { ProcedureCall procedureCall = entityManager.unwrap( Session.class ).createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.getOutputParameterValue( 2 ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java index cbb34e7f51..da25144c0b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/OracleStoredProcedureTest.java @@ -23,8 +23,8 @@ import org.hibernate.procedure.ProcedureCall; import org.hibernate.query.procedure.ProcedureParameter; import org.hibernate.result.Output; import org.hibernate.result.ResultSetOutput; -import org.hibernate.type.NumericBooleanType; -import org.hibernate.type.YesNoType; +import org.hibernate.type.NumericBooleanConverter; +import org.hibernate.type.YesNoConverter; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; @@ -493,7 +493,7 @@ public class OracleStoredProcedureTest { scope.inTransaction( entityManager -> { StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_phone_validity" ) - .registerStoredProcedureParameter( 1, NumericBooleanType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, NumericBooleanConverter.class, ParameterMode.IN ) .registerStoredProcedureParameter( 2, Class.class, ParameterMode.REF_CURSOR ) .setParameter( 1, true ); @@ -521,7 +521,7 @@ public class OracleStoredProcedureTest { scope.inTransaction( entityManager -> { StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_votes" ) - .registerStoredProcedureParameter( 1, YesNoType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, YesNoConverter.class, ParameterMode.IN ) .registerStoredProcedureParameter( 2, Class.class, ParameterMode.REF_CURSOR ) .setParameter( 1, true ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java index b5eccdb05c..6a77f5b6c9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java @@ -22,7 +22,7 @@ import org.hibernate.Session; import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.procedure.ProcedureCall; -import org.hibernate.type.StringType; +import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; @@ -366,7 +366,7 @@ public class PostgreSQLStoredProcedureTest extends BaseEntityManagerFunctionalTe doInJPA( this::entityManagerFactory, entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ).enablePassingNulls( true ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ).enablePassingNulls( true ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( 1, null ); @@ -378,7 +378,7 @@ public class PostgreSQLStoredProcedureTest extends BaseEntityManagerFunctionalTe doInJPA( this::entityManagerFactory, entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ).enablePassingNulls( true ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ).enablePassingNulls( true ); procedureCall.registerParameter( 2, Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( 1, "test" ); @@ -395,7 +395,7 @@ public class PostgreSQLStoredProcedureTest extends BaseEntityManagerFunctionalTe doInJPA( this::entityManagerFactory, entityManager -> { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( "param", StringType.class, ParameterMode.IN ); + procedureCall.registerParameter( "param", StandardBasicTypes.STRING, ParameterMode.IN ); procedureCall.registerParameter( "result", Boolean.class, ParameterMode.OUT ); procedureCall.setParameter( "param", null ); @@ -410,7 +410,7 @@ public class PostgreSQLStoredProcedureTest extends BaseEntityManagerFunctionalTe try { ProcedureCall procedureCall = entityManager.unwrap( Session.class ) .createStoredProcedureCall( "sp_is_null" ); - procedureCall.registerParameter( "param", StringType.class, ParameterMode.IN ); + procedureCall.registerParameter( "param", StandardBasicTypes.STRING, ParameterMode.IN ); procedureCall.registerParameter( "result", Boolean.class, ParameterMode.OUT ); procedureCall.getOutputParameterValue( "result" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/StoredProcedureParameterTypeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/StoredProcedureParameterTypeTest.java index ed0ea2a722..e24d5f98eb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/StoredProcedureParameterTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/StoredProcedureParameterTypeTest.java @@ -30,36 +30,10 @@ import javax.sql.rowset.serial.SerialBlob; import javax.sql.rowset.serial.SerialClob; import org.hibernate.procedure.ProcedureCall; -import org.hibernate.type.BigDecimalType; -import org.hibernate.type.BigIntegerType; -import org.hibernate.type.BinaryType; -import org.hibernate.type.BlobType; -import org.hibernate.type.BooleanType; -import org.hibernate.type.ByteType; -import org.hibernate.type.CalendarType; -import org.hibernate.type.CharArrayType; -import org.hibernate.type.CharacterType; -import org.hibernate.type.ClassType; -import org.hibernate.type.ClobType; -import org.hibernate.type.CurrencyType; -import org.hibernate.type.DateType; -import org.hibernate.type.DoubleType; -import org.hibernate.type.FloatType; -import org.hibernate.type.IntegerType; -import org.hibernate.type.LocaleType; -import org.hibernate.type.LongType; -import org.hibernate.type.MaterializedClobType; -import org.hibernate.type.NumericBooleanType; -import org.hibernate.type.ShortType; -import org.hibernate.type.StringType; -import org.hibernate.type.TextType; -import org.hibernate.type.TimeType; -import org.hibernate.type.TimeZoneType; -import org.hibernate.type.TimestampType; -import org.hibernate.type.TrueFalseType; -import org.hibernate.type.UUIDBinaryType; -import org.hibernate.type.UrlType; -import org.hibernate.type.YesNoType; +import org.hibernate.type.NumericBooleanConverter; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.TrueFalseConverter; +import org.hibernate.type.YesNoConverter; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.orm.junit.DomainModel; @@ -86,29 +60,71 @@ public class StoredProcedureParameterTypeTest { public void testNumericBooleanTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery( "test" ) - .registerStoredProcedureParameter( 1, NumericBooleanType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, StandardBasicTypes.NUMERIC_BOOLEAN, ParameterMode.IN ) .registerStoredProcedureParameter( 2, String.class, ParameterMode.OUT ) .setParameter( 1, false ) ); } + @Test + @TestForIssue( jiraKey = "HHH-12661" ) + public void testNumericBooleanTypeConverterInParameter(SessionFactoryScope scope) { + scope.inTransaction( + session -> session.createStoredProcedureQuery( "test" ) + .registerStoredProcedureParameter( 1, NumericBooleanConverter.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 2, String.class, ParameterMode.OUT ) + .setParameter( 1, false ) + ); + } + @Test @TestForIssue( jiraKey = "HHH-12661" ) public void testYesNoTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery( "test" ) - .registerStoredProcedureParameter( 1, YesNoType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, StandardBasicTypes.YES_NO, ParameterMode.IN ) + .registerStoredProcedureParameter( 2, String.class, ParameterMode.OUT ) + .setParameter( 1, false ) + ); + } + + @Test + @TestForIssue( jiraKey = "HHH-12661" ) + public void testYesNoTypeConverterInParameter(SessionFactoryScope scope) { + scope.inTransaction( + session -> session.createStoredProcedureQuery( "test" ) + .registerStoredProcedureParameter( 1, YesNoConverter.class, ParameterMode.IN ) .registerStoredProcedureParameter( 2, String.class, ParameterMode.OUT ) .setParameter( 1, false ) ); } + @Test + @TestForIssue( jiraKey = "HHH-12661" ) + public void testTrueFalseTypeInParameter(SessionFactoryScope scope) { + scope.inTransaction( + session -> session.createStoredProcedureQuery("test") + .registerStoredProcedureParameter( 1, StandardBasicTypes.TRUE_FALSE, ParameterMode.IN) + .setParameter(1, false) + ); + } + + @Test + @TestForIssue( jiraKey = "HHH-12661" ) + public void testTrueFalseTypeConverterInParameter(SessionFactoryScope scope) { + scope.inTransaction( + session -> session.createStoredProcedureQuery("test") + .registerStoredProcedureParameter( 1, TrueFalseConverter.class, ParameterMode.IN) + .setParameter(1, false) + ); + } + @Test @TestForIssue( jiraKey = "HHH-12661" ) public void testStringTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, StringType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN) .setParameter(1, TEST_STRING) ); } @@ -118,7 +134,7 @@ public class StoredProcedureParameterTypeTest { public void testMaterializedClobTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, MaterializedClobType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.MATERIALIZED_CLOB, ParameterMode.IN) .setParameter(1, TEST_STRING) ); } @@ -128,7 +144,7 @@ public class StoredProcedureParameterTypeTest { public void testTextTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, TextType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.TEXT, ParameterMode.IN) .setParameter(1, TEST_STRING) ); } @@ -138,27 +154,17 @@ public class StoredProcedureParameterTypeTest { public void testCharacterTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, CharacterType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CHARACTER, ParameterMode.IN) .setParameter(1, 'a') ); } - @Test - @TestForIssue( jiraKey = "HHH-12661" ) - public void testTrueFalseTypeInParameter(SessionFactoryScope scope) { - scope.inTransaction( - session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, TrueFalseType.class, ParameterMode.IN) - .setParameter(1, false) - ); - } - @Test @TestForIssue( jiraKey = "HHH-12661" ) public void testBooleanTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, BooleanType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BOOLEAN, ParameterMode.IN) .setParameter(1, false) ); } @@ -168,7 +174,7 @@ public class StoredProcedureParameterTypeTest { public void testByteTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, ByteType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BYTE, ParameterMode.IN) .setParameter(1, (byte) 'a') ); } @@ -178,7 +184,7 @@ public class StoredProcedureParameterTypeTest { public void testShortTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, ShortType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.SHORT, ParameterMode.IN) .setParameter(1, (short) 2) ); } @@ -188,7 +194,7 @@ public class StoredProcedureParameterTypeTest { public void testIntegerTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, IntegerType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.INTEGER, ParameterMode.IN) .setParameter(1, 2) ); } @@ -198,7 +204,7 @@ public class StoredProcedureParameterTypeTest { public void testLongTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, LongType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.LONG, ParameterMode.IN) .setParameter(1, 2L) ); } @@ -207,7 +213,7 @@ public class StoredProcedureParameterTypeTest { public void testFloatTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, FloatType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.FLOAT, ParameterMode.IN) .setParameter(1, 2.0F) ); } @@ -217,7 +223,7 @@ public class StoredProcedureParameterTypeTest { public void testDoubleTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, DoubleType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.DOUBLE, ParameterMode.IN) .setParameter(1, 2.0D) ); } @@ -227,7 +233,7 @@ public class StoredProcedureParameterTypeTest { public void testBigIntegerTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, BigIntegerType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BIG_INTEGER, ParameterMode.IN) .setParameter( 1, BigInteger.ONE) ); } @@ -237,7 +243,7 @@ public class StoredProcedureParameterTypeTest { public void testBigDecimalTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, BigDecimalType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BIG_DECIMAL, ParameterMode.IN) .setParameter( 1, BigDecimal.ONE) ); } @@ -247,7 +253,7 @@ public class StoredProcedureParameterTypeTest { public void testTimestampTypeDateInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, TimestampType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.TIMESTAMP, ParameterMode.IN) .setParameter(1, new Date()) ); } @@ -257,7 +263,7 @@ public class StoredProcedureParameterTypeTest { public void testTimestampTypeTimestampInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter(1, TimestampType.class, ParameterMode.IN) + .registerStoredProcedureParameter(1, StandardBasicTypes.TIMESTAMP, ParameterMode.IN) .setParameter( 1, Timestamp.valueOf( LocalDateTime.now())) ); } @@ -267,7 +273,7 @@ public class StoredProcedureParameterTypeTest { public void testTimeTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, TimeType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.TIME, ParameterMode.IN) .setParameter( 1, Time.valueOf( LocalTime.now())) ); } @@ -277,7 +283,7 @@ public class StoredProcedureParameterTypeTest { public void testDateTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, DateType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.DATE, ParameterMode.IN) .setParameter(1, java.sql.Date.valueOf( LocalDate.now())) ); } @@ -287,7 +293,7 @@ public class StoredProcedureParameterTypeTest { public void testCalendarTypeCalendarInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, CalendarType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CALENDAR, ParameterMode.IN) .setParameter( 1, Calendar.getInstance()) ); } @@ -297,7 +303,7 @@ public class StoredProcedureParameterTypeTest { public void testCurrencyTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, CurrencyType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CURRENCY, ParameterMode.IN) .setParameter( 1, Currency.getAvailableCurrencies().iterator().next()) ); } @@ -307,7 +313,7 @@ public class StoredProcedureParameterTypeTest { public void testLocaleTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, LocaleType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.LOCALE, ParameterMode.IN) .setParameter( 1, Locale.ENGLISH) ); } @@ -317,7 +323,7 @@ public class StoredProcedureParameterTypeTest { public void testTimeZoneTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, TimeZoneType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.TIMEZONE, ParameterMode.IN) .setParameter( 1, TimeZone.getTimeZone( ZoneId.systemDefault())) ); } @@ -328,7 +334,7 @@ public class StoredProcedureParameterTypeTest { final URL url = new URL( "http://example.com"); scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, UrlType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.URL, ParameterMode.IN) .setParameter(1, url) ); } @@ -338,7 +344,7 @@ public class StoredProcedureParameterTypeTest { public void testClassTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, ClassType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CLASS, ParameterMode.IN) .setParameter(1, Class.class) ); } @@ -349,7 +355,7 @@ public class StoredProcedureParameterTypeTest { final Blob blob = new SerialBlob( TEST_BYTE_ARRAY); scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, BlobType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BLOB, ParameterMode.IN) .setParameter(1, blob) ); } @@ -360,7 +366,7 @@ public class StoredProcedureParameterTypeTest { final Clob clob = new SerialClob( TEST_CHAR_ARRAY); scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, ClobType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CLOB, ParameterMode.IN) .setParameter(1, clob) ); } @@ -370,7 +376,7 @@ public class StoredProcedureParameterTypeTest { public void testBinaryTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, BinaryType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.BINARY, ParameterMode.IN) .setParameter(1, TEST_BYTE_ARRAY) ); } @@ -380,7 +386,7 @@ public class StoredProcedureParameterTypeTest { public void testCharArrayTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, CharArrayType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.CHAR_ARRAY, ParameterMode.IN) .setParameter(1, TEST_CHAR_ARRAY) ); } @@ -390,7 +396,7 @@ public class StoredProcedureParameterTypeTest { public void testUUIDBinaryTypeInParameter(SessionFactoryScope scope) { scope.inTransaction( session -> session.createStoredProcedureQuery("test") - .registerStoredProcedureParameter( 1, UUIDBinaryType.class, ParameterMode.IN) + .registerStoredProcedureParameter( 1, StandardBasicTypes.UUID_BINARY, ParameterMode.IN) .setParameter( 1, UUID.randomUUID()) ); } @@ -401,7 +407,7 @@ public class StoredProcedureParameterTypeTest { scope.inTransaction( session -> { ProcedureCall procedureCall = session.createStoredProcedureCall( "test" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ).enablePassingNulls( true ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ).enablePassingNulls( true ); procedureCall.setParameter( 1, null ); } ); @@ -413,7 +419,7 @@ public class StoredProcedureParameterTypeTest { scope.inTransaction( session -> { ProcedureCall procedureCall = session.createStoredProcedureCall( "test" ); - procedureCall.registerParameter( 1, StringType.class, ParameterMode.IN ); + procedureCall.registerParameter( 1, StandardBasicTypes.STRING, ParameterMode.IN ); procedureCall.setParameter( 1, null ); } ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java index f24646a8b7..a29530cd25 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java @@ -31,11 +31,7 @@ import org.hibernate.query.Query; import org.hibernate.transform.BasicTransformerAdapter; import org.hibernate.transform.DistinctRootEntityResultTransformer; import org.hibernate.transform.Transformers; -import org.hibernate.type.FloatType; -import org.hibernate.type.LongType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.StringType; -import org.hibernate.type.TimestampType; import org.hibernate.testing.FailureExpected; import org.hibernate.testing.RequiresDialect; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/OracleLongLobTypeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/OracleLongLobTypeTest.java new file mode 100644 index 0000000000..0528de9e39 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/OracleLongLobTypeTest.java @@ -0,0 +1,151 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.type; + +import java.sql.Blob; +import java.sql.Clob; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Lob; + +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.spi.MetadataImplementor; +import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.Dialect; +import org.hibernate.dialect.Oracle10gDialect; +import org.hibernate.dialect.Oracle12cDialect; +import org.hibernate.dialect.Oracle8iDialect; +import org.hibernate.dialect.Oracle9iDialect; +import org.hibernate.dialect.OracleDialect; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.type.BasicType; +import org.hibernate.type.BasicTypeReference; +import org.hibernate.type.StandardBasicTypes; +import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeDescriptorRegistry; + +import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.junit4.BaseUnitTestCase; + +import org.junit.Test; + +import static org.junit.Assert.assertSame; + +/** + * A test asserting LONG/LONGRAW versus CLOB/BLOB resolution for various Oracle Dialects + * + * @author Steve Ebersole + */ +public class OracleLongLobTypeTest extends BaseUnitTestCase { + @Test + public void testOracle8() { + check( Oracle8iDialect.class, Primitives.class, StandardBasicTypes.BINARY, StandardBasicTypes.CHAR_ARRAY ); + check( Oracle8iDialect.class, LobPrimitives.class, StandardBasicTypes.MATERIALIZED_BLOB, StandardBasicTypes.MATERIALIZED_CLOB_CHAR_ARRAY ); + check( Oracle8iDialect.class, LobLocators.class, StandardBasicTypes.BLOB, StandardBasicTypes.CLOB ); + } + + @Test + public void testOracle9() { + check( Oracle9iDialect.class, Primitives.class, StandardBasicTypes.BINARY, StandardBasicTypes.CHAR_ARRAY ); + check( Oracle9iDialect.class, LobPrimitives.class, StandardBasicTypes.MATERIALIZED_BLOB, StandardBasicTypes.MATERIALIZED_CLOB_CHAR_ARRAY ); + check( Oracle9iDialect.class, LobLocators.class, StandardBasicTypes.BLOB, StandardBasicTypes.CLOB ); + } + + @Test + public void testOracle10() { + check( Oracle10gDialect.class, Primitives.class, StandardBasicTypes.BINARY, StandardBasicTypes.CHAR_ARRAY ); + check( Oracle10gDialect.class, LobPrimitives.class, StandardBasicTypes.MATERIALIZED_BLOB, StandardBasicTypes.MATERIALIZED_CLOB_CHAR_ARRAY ); + check( Oracle10gDialect.class, LobLocators.class, StandardBasicTypes.BLOB, StandardBasicTypes.CLOB ); + } + + @Test + @TestForIssue( jiraKey = "HHH-10345" ) + public void testOracle12() { + check( Oracle12cDialect.class, Primitives.class, StandardBasicTypes.BINARY, StandardBasicTypes.CHAR_ARRAY ); + check( Oracle12cDialect.class, LobPrimitives.class, StandardBasicTypes.MATERIALIZED_BLOB, StandardBasicTypes.MATERIALIZED_CLOB_CHAR_ARRAY ); + check( Oracle12cDialect.class, LobLocators.class, StandardBasicTypes.BLOB, StandardBasicTypes.CLOB ); + } + + @Test + @TestForIssue( jiraKey = "HHH-10345" ) + public void testOracle12PreferLongRaw() { + check( Oracle12cDialect.class, Primitives.class, StandardBasicTypes.BINARY, StandardBasicTypes.CHAR_ARRAY, true ); + check( Oracle12cDialect.class, LobPrimitives.class, StandardBasicTypes.MATERIALIZED_BLOB, StandardBasicTypes.MATERIALIZED_CLOB_CHAR_ARRAY, true ); + check( Oracle12cDialect.class, LobLocators.class, StandardBasicTypes.BLOB, StandardBasicTypes.CLOB, true ); + } + + private void check( + Class dialectClass, + Class entityClass, + BasicTypeReference binaryTypeClass, + BasicTypeReference charTypeClass) { + check( dialectClass, entityClass, binaryTypeClass, charTypeClass, false ); + } + + private void check( + Class dialectClass, + Class entityClass, + BasicTypeReference binaryTypeClass, + BasicTypeReference charTypeClass, + boolean preferLongRaw) { + StandardServiceRegistry ssr = new StandardServiceRegistryBuilder() + .applySetting( AvailableSettings.DIALECT, dialectClass.getName() ) + .applySetting( OracleDialect.PREFER_LONG_RAW, Boolean.toString( preferLongRaw ) ) + .applySetting( "hibernate.temp.use_jdbc_metadata_defaults", false ) + .build(); + + try { + final MetadataImplementor mappings = (MetadataImplementor) new MetadataSources( ssr ) + .addAnnotatedClass( entityClass ) + .buildMetadata(); + mappings.validate(); + + final PersistentClass entityBinding = mappings.getEntityBinding( entityClass.getName() ); + final JdbcTypeDescriptorRegistry jdbcTypeRegistry = mappings.getTypeConfiguration() + .getJdbcTypeDescriptorRegistry(); + + BasicType type; + + type = (BasicType) entityBinding.getProperty( "binaryData" ).getType(); + assertSame( jdbcTypeRegistry.getDescriptor( binaryTypeClass.getSqlTypeCode() ), type.getJdbcTypeDescriptor() ); + type = (BasicType) entityBinding.getProperty( "characterData" ).getType(); + assertSame( jdbcTypeRegistry.getDescriptor( charTypeClass.getSqlTypeCode() ), type.getJdbcTypeDescriptor() ); + } + finally { + StandardServiceRegistryBuilder.destroy( ssr ); + } + } + + @Entity + public static class Primitives { + @Id + public Integer id; + public byte[] binaryData; + public char[] characterData; + } + + @Entity + public static class LobPrimitives { + @Id + public Integer id; + @Lob + public byte[] binaryData; + @Lob + public char[] characterData; + } + + @Entity + public static class LobLocators { + @Id + public Integer id; + @Lob + public Blob binaryData; + @Lob + public Clob characterData; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java index b9eb3bd439..c560ce3d72 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java @@ -25,7 +25,6 @@ import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.query.NativeQuery; import org.hibernate.stat.Statistics; -import org.hibernate.type.DateType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.SkipForDialect; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java index cd4419151f..7b7a954f49 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/type/dynamicparameterized/MyStringType.java @@ -32,7 +32,6 @@ import java.util.Properties; import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.StringType; import org.hibernate.usertype.DynamicParameterizedType; import org.hibernate.usertype.UserType; diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/ImageTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/ImageTest.java index 16befdf055..932847b456 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/ImageTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/ImageTest.java @@ -8,7 +8,7 @@ package org.hibernate.test.lob; /** * Tests eager materialization and mutation of data mapped by - * {@link org.hibernate.type.ImageType}. + * {@link org.hibernate.type.StandardBasicTypes#IMAGE}. * * @author Gail Badner */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedBlobTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedBlobTest.java index 26d827fe98..8ba943c860 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedBlobTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedBlobTest.java @@ -11,7 +11,7 @@ import org.hibernate.testing.RequiresDialectFeature; /** * Tests eager materialization and mutation of data mapped by - * {@link org.hibernate.type.MaterializedBlobType}. + * {@link org.hibernate.type.StandardBasicTypes#MATERIALIZED_BLOB}. * * @author Gail Badner */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedClobTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedClobTest.java index a2670a2fbc..2a82bc7c4c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedClobTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/MaterializedClobTest.java @@ -11,7 +11,7 @@ import org.hibernate.testing.RequiresDialectFeature; /** * Tests eager materialization and mutation of data mapped by - * {@link org.hibernate.type.MaterializedClobType}. + * {@link org.hibernate.type.StandardBasicTypes#MATERIALIZED_CLOB}. * * @author Gail Badner */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/lob/TextTest.java b/hibernate-core/src/test/java/org/hibernate/test/lob/TextTest.java index 35f5630dbe..bac408643c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/lob/TextTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/lob/TextTest.java @@ -8,7 +8,7 @@ package org.hibernate.test.lob; /** * Test eager materialization and mutation data mapped by - * #{@link org.hibernate.type.TextType}. + * #{@link org.hibernate.type.StandardBasicTypes#TEXT}. * * @author Gail Badner */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java index af53e74b04..d7f3c77c77 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/procedure/HANAStoredProcedureTest.java @@ -38,8 +38,9 @@ import org.hibernate.result.Output; import org.hibernate.result.ResultSetOutput; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; -import org.hibernate.type.NumericBooleanType; -import org.hibernate.type.YesNoType; + +import org.hibernate.type.NumericBooleanConverter; +import org.hibernate.type.YesNoConverter; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -508,7 +509,7 @@ public class HANAStoredProcedureTest extends BaseEntityManagerFunctionalTestCase doInJPA( this::entityManagerFactory, entityManager -> { StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_phone_validity" ) - .registerStoredProcedureParameter( 1, NumericBooleanType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, NumericBooleanConverter.class, ParameterMode.IN ) .registerStoredProcedureParameter( 2, Class.class, ParameterMode.REF_CURSOR ) .setParameter( 1, true ); @@ -534,7 +535,7 @@ public class HANAStoredProcedureTest extends BaseEntityManagerFunctionalTestCase doInJPA( this::entityManagerFactory, entityManager -> { StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_votes" ) - .registerStoredProcedureParameter( 1, YesNoType.class, ParameterMode.IN ) + .registerStoredProcedureParameter( 1, YesNoConverter.class, ParameterMode.IN ) .registerStoredProcedureParameter( 2, Class.class, ParameterMode.REF_CURSOR ) .setParameter( 1, true ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/temporal/MySQL57TimestampPropertyTest.java b/hibernate-core/src/test/java/org/hibernate/test/temporal/MySQL57TimestampPropertyTest.java index 54168a198d..28d0388d18 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/temporal/MySQL57TimestampPropertyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/temporal/MySQL57TimestampPropertyTest.java @@ -22,7 +22,6 @@ import org.hibernate.annotations.Generated; import org.hibernate.annotations.GenerationTime; import org.hibernate.dialect.MySQL57Dialect; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.TimestampType; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java b/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java index d030f31e03..8ecb72464a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/temporal/TimePropertyTest.java @@ -22,7 +22,6 @@ import org.hibernate.query.Query; import org.hibernate.Session; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.TimeType; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; diff --git a/hibernate-core/src/test/java/org/hibernate/test/type/OracleLongLobTypeTest.java b/hibernate-core/src/test/java/org/hibernate/test/type/OracleLongLobTypeTest.java deleted file mode 100644 index 3bdbeabaff..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/type/OracleLongLobTypeTest.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.type; - -import java.sql.Blob; -import java.sql.Clob; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import jakarta.persistence.Lob; - -import org.hibernate.boot.MetadataSources; -import org.hibernate.boot.registry.StandardServiceRegistry; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.boot.spi.MetadataImplementor; -import org.hibernate.cfg.AvailableSettings; -import org.hibernate.dialect.Dialect; -import org.hibernate.dialect.Oracle10gDialect; -import org.hibernate.dialect.Oracle12cDialect; -import org.hibernate.dialect.Oracle8iDialect; -import org.hibernate.dialect.Oracle9iDialect; -import org.hibernate.internal.util.config.ConfigurationHelper; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.type.BinaryType; -import org.hibernate.type.BlobType; -import org.hibernate.type.CharArrayType; -import org.hibernate.type.ClobType; -import org.hibernate.type.MaterializedBlobType; -import org.hibernate.type.PrimitiveCharacterArrayClobType; -import org.hibernate.type.Type; - -import org.hibernate.testing.TestForIssue; -import org.hibernate.testing.junit4.BaseUnitTestCase; - -import org.junit.Test; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertThat; - -/** - * A test asserting LONG/LONGRAW versus CLOB/BLOB resolution for various Oracle Dialects - * - * @author Steve Ebersole - */ -public class OracleLongLobTypeTest extends BaseUnitTestCase { - @Test - public void testOracle8() { - check( Oracle8iDialect.class, Primitives.class, BinaryType.class, CharArrayType.class ); - check( Oracle8iDialect.class, LobPrimitives.class, MaterializedBlobType.class, PrimitiveCharacterArrayClobType.class ); - check( Oracle8iDialect.class, LobLocators.class, BlobType.class, ClobType.class ); - } - - @Test - public void testOracle9() { - check( Oracle9iDialect.class, Primitives.class, BinaryType.class, CharArrayType.class ); - check( Oracle9iDialect.class, LobPrimitives.class, MaterializedBlobType.class, PrimitiveCharacterArrayClobType.class ); - check( Oracle9iDialect.class, LobLocators.class, BlobType.class, ClobType.class ); - } - - @Test - public void testOracle10() { - check( Oracle10gDialect.class, Primitives.class, BinaryType.class, CharArrayType.class ); - check( Oracle10gDialect.class, LobPrimitives.class, MaterializedBlobType.class, PrimitiveCharacterArrayClobType.class ); - check( Oracle10gDialect.class, LobLocators.class, BlobType.class, ClobType.class ); - } - - @Test - @TestForIssue( jiraKey = "HHH-10345" ) - public void testOracle12() { - check( Oracle12cDialect.class, Primitives.class, MaterializedBlobType.class, CharArrayType.class ); - check( Oracle12cDialect.class, LobPrimitives.class, MaterializedBlobType.class, PrimitiveCharacterArrayClobType.class ); - check( Oracle12cDialect.class, LobLocators.class, BlobType.class, ClobType.class ); - } - - @Test - @TestForIssue( jiraKey = "HHH-10345" ) - public void testOracle12PreferLongRaw() { - check( Oracle12cDialect.class, Primitives.class, BinaryType.class, CharArrayType.class, true ); - check( Oracle12cDialect.class, LobPrimitives.class, MaterializedBlobType.class, PrimitiveCharacterArrayClobType.class, true ); - check( Oracle12cDialect.class, LobLocators.class, BlobType.class, ClobType.class, true ); - } - - private void check( - Class dialectClass, - Class entityClass, - Class binaryTypeClass, - Class charTypeClass) { - check( dialectClass, entityClass, binaryTypeClass, charTypeClass, false ); - } - - private void check( - Class dialectClass, - Class entityClass, - Class binaryTypeClass, - Class charTypeClass, - boolean preferLongRaw) { - StandardServiceRegistry ssr = new StandardServiceRegistryBuilder() - .applySetting( AvailableSettings.DIALECT, dialectClass.getName() ) - .applySetting( Oracle12cDialect.PREFER_LONG_RAW, Boolean.toString( preferLongRaw ) ) - .applySetting( "hibernate.temp.use_jdbc_metadata_defaults", false ) - .build(); - - try { - final MetadataImplementor mappings = (MetadataImplementor) new MetadataSources( ssr ) - .addAnnotatedClass( entityClass ) - .buildMetadata(); - mappings.validate(); - - final PersistentClass entityBinding = mappings.getEntityBinding( entityClass.getName() ); - - assertThat( entityBinding.getProperty( "binaryData" ).getType(), instanceOf( binaryTypeClass ) ); - assertThat( entityBinding.getProperty( "characterData" ).getType(), instanceOf( charTypeClass ) ); - } - finally { - StandardServiceRegistryBuilder.destroy( ssr ); - } - } - - @Entity - public static class Primitives { - @Id - public Integer id; - public byte[] binaryData; - public char[] characterData; - } - - @Entity - public static class LobPrimitives { - @Id - public Integer id; - @Lob - public byte[] binaryData; - @Lob - public char[] characterData; - } - - @Entity - public static class LobLocators { - @Id - public Integer id; - @Lob - public Blob binaryData; - @Lob - public Clob characterData; - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java b/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java index 14ae03df81..a133249f86 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/usertype/StringWrapperUserType.java @@ -9,7 +9,6 @@ import java.util.Objects; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.StringType; import org.hibernate.usertype.UserType; import org.jboss.logging.Logger; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java index 05f3ce0ee2..a8e1d932d0 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java @@ -36,8 +36,6 @@ import org.hibernate.envers.internal.revisioninfo.RevisionInfoNumberReader; import org.hibernate.envers.internal.revisioninfo.RevisionInfoQueryCreator; import org.hibernate.envers.internal.tools.MutableBoolean; import org.hibernate.mapping.PersistentClass; -import org.hibernate.type.LongType; -import org.hibernate.type.Type; import org.dom4j.Document; import org.dom4j.Element; @@ -51,7 +49,7 @@ public class RevisionInfoConfiguration { private PropertyData revisionInfoIdData; private PropertyData revisionInfoTimestampData; private PropertyData modifiedEntityNamesData; - private Type revisionInfoTimestampType; + private String revisionInfoTimestampTypeName; private GlobalConfiguration globalCfg; private XMLHelper xmlHelper; @@ -70,7 +68,7 @@ public class RevisionInfoConfiguration { revisionInfoIdData = new PropertyData( "id", "id", "field", null ); revisionInfoTimestampData = new PropertyData( "timestamp", "timestamp", "field", null ); modifiedEntityNamesData = new PropertyData( "modifiedEntityNames", "modifiedEntityNames", "field", null ); - revisionInfoTimestampType = new LongType(); + revisionInfoTimestampTypeName = "long"; revisionPropType = "integer"; } @@ -99,7 +97,7 @@ public class RevisionInfoConfiguration { final Element timestampProperty = MetadataTools.addProperty( classMapping, revisionInfoTimestampData.getName(), - revisionInfoTimestampType.getName(), + revisionInfoTimestampTypeName, true, false ); @@ -352,7 +350,7 @@ public class RevisionInfoConfiguration { revisionInfoEntityName = persistentClass.getEntityName(); revisionInfoClass = persistentClass.getMappedClass(); final Class revisionListenerClass = getRevisionListenerClass( revisionEntity.value() ); - revisionInfoTimestampType = persistentClass.getProperty( revisionInfoTimestampData.getName() ).getType(); + revisionInfoTimestampTypeName = persistentClass.getProperty( revisionInfoTimestampData.getName() ).getType().getName(); if ( globalCfg.isTrackEntitiesChangedInRevision() || ( globalCfg.isUseRevisionEntityWithNativeId() && DefaultTrackingModifiedEntitiesRevisionEntity.class .isAssignableFrom( revisionInfoClass ) ) @@ -447,7 +445,7 @@ public class RevisionInfoConfiguration { } private boolean isTimestampAsDate() { - final String typename = revisionInfoTimestampType.getName(); + final String typename = revisionInfoTimestampTypeName; return "date".equals( typename ) || "time".equals( typename ) || "timestamp".equals( typename ); } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMetadataGenerator.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMetadataGenerator.java index a51d932584..98b50513e9 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMetadataGenerator.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/metadata/CollectionMetadataGenerator.java @@ -6,6 +6,7 @@ */ package org.hibernate.envers.configuration.internal.metadata; +import java.sql.Types; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -79,12 +80,11 @@ import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Table; import org.hibernate.mapping.Value; import org.hibernate.type.BagType; +import org.hibernate.type.BasicType; import org.hibernate.type.ComponentType; import org.hibernate.type.ListType; import org.hibernate.type.ManyToOneType; import org.hibernate.type.MapType; -import org.hibernate.type.MaterializedClobType; -import org.hibernate.type.MaterializedNClobType; import org.hibernate.type.SetType; import org.hibernate.type.SortedMapType; import org.hibernate.type.SortedSetType; @@ -1103,8 +1103,12 @@ public final class CollectionMetadataGenerator { private boolean isKeyRevisionTypeInId() { if ( propertyValue instanceof org.hibernate.mapping.Map ) { final Type type = propertyValue.getKey().getType(); - if ( !type.isComponentType() && !type.isAssociationType() ) { - return ( type instanceof MaterializedClobType ) || ( type instanceof MaterializedNClobType ); + if ( !type.isComponentType() && !type.isAssociationType() && type instanceof BasicType ) { + final BasicType basicType = (BasicType) type; + return basicType.getJavaType() == String.class && ( + basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.CLOB + || basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.NCLOB + ); } } return false; @@ -1119,8 +1123,12 @@ public final class CollectionMetadataGenerator { if ( propertyValue instanceof org.hibernate.mapping.Map ) { final Type type = propertyValue.getElement().getType(); // we're only interested in basic types - if ( !type.isComponentType() && !type.isAssociationType() ) { - return ( type instanceof MaterializedClobType ) || ( type instanceof MaterializedNClobType ); + if ( !type.isComponentType() && !type.isAssociationType() && type instanceof BasicType ) { + final BasicType basicType = (BasicType) type; + return basicType.getJavaType() == String.class && ( + basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.CLOB + || basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.NCLOB + ); } } return false; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/internal/ValidityAuditStrategy.java b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/internal/ValidityAuditStrategy.java index b16bd77ebc..181946c104 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/strategy/internal/ValidityAuditStrategy.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/strategy/internal/ValidityAuditStrategy.java @@ -12,6 +12,7 @@ import static org.hibernate.envers.internal.entities.mapper.relation.query.Query import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.sql.Types; import java.util.Date; import java.util.List; import java.util.Map; @@ -43,13 +44,11 @@ import org.hibernate.persister.entity.UnionSubclassEntityPersister; import org.hibernate.property.access.spi.Getter; import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.Update; +import org.hibernate.type.BasicType; import org.hibernate.type.CollectionType; import org.hibernate.type.ComponentType; import org.hibernate.type.MapType; -import org.hibernate.type.MaterializedClobType; -import org.hibernate.type.MaterializedNClobType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.TimestampType; import org.hibernate.type.Type; /** @@ -488,11 +487,22 @@ public class ValidityAuditStrategy implements AuditStrategy { // required for Embeddables return true; } - else if ( collectionElementType instanceof MaterializedClobType || collectionElementType instanceof MaterializedNClobType ) { + else if ( isMaterializedClob( collectionElementType ) ) { // for Map<> using @Lob annotations return collectionType instanceof MapType; } } return false; } + + private boolean isMaterializedClob(Type collectionElementType) { + if ( collectionElementType instanceof BasicType ) { + final BasicType basicType = (BasicType) collectionElementType; + return basicType.getJavaType() == String.class && ( + basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.CLOB + || basicType.getJdbcTypeDescriptor().getJdbcTypeCode() == Types.NCLOB + ); + } + return false; + } } diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java index 36a8b5ae4c..0c7eac378b 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/customtype/UnspecifiedEnumTypeTest.java @@ -15,7 +15,6 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.orm.test.envers.BaseEnversFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; import org.hibernate.orm.test.envers.entities.customtype.UnspecifiedEnumTypeEntity; -import org.hibernate.type.IntegerType; import org.hibernate.type.StandardBasicTypes; import org.junit.Assert; 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 c1d52fbc2b..3ee4149120 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 @@ -14,7 +14,6 @@ import java.sql.Types; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.IntegerType; import org.hibernate.usertype.UserType; public class AgeType implements UserType { diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/multiplerelations/GroupMemberTest.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/multiplerelations/GroupMemberTest.java index 3fe1d7872e..50a0d266e7 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/multiplerelations/GroupMemberTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/multiplerelations/GroupMemberTest.java @@ -26,7 +26,6 @@ import org.hibernate.envers.AuditMappedBy; import org.hibernate.envers.Audited; import org.hibernate.orm.test.envers.BaseEnversJPAFunctionalTestCase; import org.hibernate.orm.test.envers.Priority; -import org.hibernate.type.IntegerType; import org.hibernate.type.StandardBasicTypes; import org.hibernate.testing.TestForIssue; diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java index 10b74ec85c..98f89e62fc 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/BaseNonConfigCoreFunctionalTestCase.java @@ -6,14 +6,12 @@ */ package org.hibernate.testing.junit4; -import java.sql.Blob; -import java.sql.Clob; import java.sql.Connection; -import java.sql.NClob; import java.sql.SQLException; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.function.Consumer; import java.util.function.Function; @@ -52,9 +50,6 @@ import org.hibernate.mapping.SimpleValue; import org.hibernate.query.sqm.mutation.internal.idtable.GlobalTemporaryTableStrategy; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; import org.hibernate.resource.transaction.spi.TransactionCoordinator; -import org.hibernate.type.BlobType; -import org.hibernate.type.ClobType; -import org.hibernate.type.NClobType; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.BeforeClassOnce; @@ -351,7 +346,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { while ( props.hasNext() ) { final Property prop = (Property) props.next(); if ( prop.getValue().isSimpleValue() ) { - if ( isLob( ( (SimpleValue) prop.getValue() ).getTypeName() ) ) { + if ( isLob( (SimpleValue) prop.getValue() ) ) { hasLob = true; break; } @@ -368,7 +363,7 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { boolean isLob = false; if ( collectionBinding.getElement().isSimpleValue() ) { - isLob = isLob( ( (SimpleValue) collectionBinding.getElement() ).getTypeName() ); + isLob = isLob( (SimpleValue) collectionBinding.getElement() ); } if ( !isLob ) { @@ -377,16 +372,22 @@ public class BaseNonConfigCoreFunctionalTestCase extends BaseUnitTestCase { } } - private boolean isLob(String typeName) { - return "blob".equals( typeName ) - || "clob".equals( typeName ) - || "nclob".equals( typeName ) - || Blob.class.getName().equals( typeName ) - || Clob.class.getName().equals( typeName ) - || NClob.class.getName().equals( typeName ) - || BlobType.class.getName().equals( typeName ) - || ClobType.class.getName().equals( typeName ) - || NClobType.class.getName().equals( typeName ); + private static boolean isLob(SimpleValue value) { + final String typeName = value.getTypeName(); + if ( typeName != null ) { + String significantTypeNamePart = typeName.substring( typeName.lastIndexOf( '.' ) + 1 ) + .toLowerCase( Locale.ROOT ); + switch ( significantTypeNamePart ) { + case "blob": + case "blobtype": + case "clob": + case "clobtype": + case "nclob": + case "nclobtype": + return true; + } + } + return false; } protected void afterMetadataBuilt(Metadata metadata) { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java index 4771cf8d89..d5e38b92fa 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/BaseSessionFactoryFunctionalTest.java @@ -8,10 +8,8 @@ package org.hibernate.testing.orm.junit; import java.io.IOException; import java.io.InputStream; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.NClob; import java.util.Iterator; +import java.util.Locale; import java.util.function.Consumer; import java.util.function.Function; @@ -32,9 +30,6 @@ import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.RootClass; import org.hibernate.mapping.SimpleValue; -import org.hibernate.type.BlobType; -import org.hibernate.type.ClobType; -import org.hibernate.type.NClobType; import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl; import org.junit.jupiter.api.AfterEach; @@ -127,7 +122,7 @@ public abstract class BaseSessionFactoryFunctionalTest while ( props.hasNext() ) { final Property prop = (Property) props.next(); if ( prop.getValue().isSimpleValue() ) { - if ( isLob( ( (SimpleValue) prop.getValue() ).getTypeName() ) ) { + if ( isLob( (SimpleValue) prop.getValue() ) ) { hasLob = true; break; } @@ -144,7 +139,7 @@ public abstract class BaseSessionFactoryFunctionalTest boolean isLob = false; if ( collectionBinding.getElement().isSimpleValue() ) { - isLob = isLob( ( (SimpleValue) collectionBinding.getElement() ).getTypeName() ); + isLob = isLob( (SimpleValue) collectionBinding.getElement() ); } if ( !isLob ) { @@ -277,16 +272,22 @@ public abstract class BaseSessionFactoryFunctionalTest return DialectContext.getDialect(); } - private boolean isLob(String typeName) { - return "blob".equals( typeName ) - || "clob".equals( typeName ) - || "nclob".equals( typeName ) - || Blob.class.getName().equals( typeName ) - || Clob.class.getName().equals( typeName ) - || NClob.class.getName().equals( typeName ) - || BlobType.class.getName().equals( typeName ) - || ClobType.class.getName().equals( typeName ) - || NClobType.class.getName().equals( typeName ); + private static boolean isLob(SimpleValue value) { + final String typeName = value.getTypeName(); + if ( typeName != null ) { + String significantTypeNamePart = typeName.substring( typeName.lastIndexOf( '.' ) + 1 ) + .toLowerCase( Locale.ROOT ); + switch ( significantTypeNamePart ) { + case "blob": + case "blobtype": + case "clob": + case "clobtype": + case "nclob": + case "nclobtype": + return true; + } + } + return false; } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java index 76a10bfc5b..6fe884d30b 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java @@ -6,10 +6,8 @@ */ package org.hibernate.testing.orm.junit; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.NClob; import java.util.Iterator; +import java.util.Locale; import java.util.Optional; import org.hibernate.boot.Metadata; @@ -18,15 +16,13 @@ import org.hibernate.boot.internal.MetadataBuilderImpl; import org.hibernate.boot.model.TypeContributor; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.spi.MetadataImplementor; +import org.hibernate.mapping.BasicValue; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.RootClass; import org.hibernate.mapping.SimpleValue; import org.hibernate.resource.beans.spi.ManagedBeanRegistry; -import org.hibernate.type.BlobType; -import org.hibernate.type.ClobType; -import org.hibernate.type.NClobType; import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.StandardDomainModel; @@ -179,7 +175,7 @@ public class DomainModelExtension while ( props.hasNext() ) { final Property prop = (Property) props.next(); if ( prop.getValue().isSimpleValue() ) { - if ( isLob( ( (SimpleValue) prop.getValue() ).getTypeName() ) ) { + if ( isLob( (SimpleValue) prop.getValue() ) ) { hasLob = true; break; } @@ -196,7 +192,7 @@ public class DomainModelExtension boolean isLob = false; if ( collectionBinding.getElement().isSimpleValue() ) { - isLob = isLob( ( (SimpleValue) collectionBinding.getElement() ).getTypeName() ); + isLob = isLob( (SimpleValue) collectionBinding.getElement() ); } if ( !isLob ) { @@ -205,16 +201,22 @@ public class DomainModelExtension } } - private static boolean isLob(String typeName) { - return "blob".equals( typeName ) - || "clob".equals( typeName ) - || "nclob".equals( typeName ) - || Blob.class.getName().equals( typeName ) - || Clob.class.getName().equals( typeName ) - || NClob.class.getName().equals( typeName ) - || BlobType.class.getName().equals( typeName ) - || ClobType.class.getName().equals( typeName ) - || NClobType.class.getName().equals( typeName ); + private static boolean isLob(SimpleValue value) { + final String typeName = value.getTypeName(); + if ( typeName != null ) { + String significantTypeNamePart = typeName.substring( typeName.lastIndexOf( '.' ) + 1 ) + .toLowerCase( Locale.ROOT ); + switch ( significantTypeNamePart ) { + case "blob": + case "blobtype": + case "clob": + case "clobtype": + case "nclob": + case "nclobtype": + return true; + } + } + return false; } @Override