Get rid of most basic type subclasses

This commit is contained in:
Christian Beikov 2021-10-11 18:16:10 +02:00
parent 4f861e13ba
commit 541302a511
111 changed files with 665 additions and 2488 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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}.

View File

@ -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;

View File

@ -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;

View File

@ -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 );
}

View File

@ -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;
/**

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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
<T> ProcedureParameter<T> registerParameter(int position, Class<T> 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 <T> The parameterized Java type of the parameter.
*
* @return {@code this}, for method chaining
* @return The parameter registration memento
*/
<T> ProcedureCall registerParameter0(int position, Class<T> type, ParameterMode mode);
<T> ProcedureParameter<T> registerParameter(int position, BasicTypeReference<T> 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 <T> 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)
<T> ProcedureParameter<T> registerParameter(String parameterName, BasicTypeReference<T> 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
<T> ProcedureCall setParameter( Parameter<T> param, T value);
@Override
ProcedureCall setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType);
@Override
ProcedureCall setParameter(Parameter<Date> 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);
}

View File

@ -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<R>
}
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> 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<R> 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 <T> ProcedureParameter<T> registerParameter(int position, Class<T> javaType, ParameterMode mode) {
final ProcedureParameterImpl procedureParameter = new ProcedureParameterImpl(
final AllowableParameterType<T> parameterType = getSessionFactory().getDomainModel().resolveQueryParameterType(
javaType
);
final ProcedureParameterImpl<T> 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 <T> ProcedureParameter<T> registerParameter(
int position,
BasicTypeReference<T> typeReference,
ParameterMode mode) {
final BasicType<T> basicType = getSessionFactory().getTypeConfiguration()
.getBasicTypeRegistry()
.resolve( typeReference );
final ProcedureParameterImpl<T> procedureParameter = new ProcedureParameterImpl<>(
position,
mode,
basicType.getJavaType(),
basicType
);
registerParameter( procedureParameter );
return procedureParameter;
}
private void registerParameter(ProcedureParameterImplementor parameter) {
@ -389,11 +444,14 @@ public class ProcedureCallImpl<R>
@Override
@SuppressWarnings("unchecked")
public <T> ProcedureParameterImplementor<T> registerParameter(String name, Class<T> javaType, ParameterMode mode) {
final AllowableParameterType<T> 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<R>
@Override
@SuppressWarnings("unchecked")
public ProcedureCall registerParameter0(String name, Class type, ParameterMode mode) {
registerParameter( name, type, mode );
return this;
public <T> ProcedureParameterImplementor<T> registerParameter(
String name,
BasicTypeReference<T> typeReference,
ParameterMode mode) {
final BasicType<T> basicType = getSessionFactory().getTypeConfiguration()
.getBasicTypeRegistry()
.resolve( typeReference );
final ProcedureParameterImpl parameter = new ProcedureParameterImpl(
name,
mode,
basicType.getJavaType(),
basicType
);
registerParameter( parameter );
return parameter;
}
@Override

View File

@ -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<R> extends ProcedureCall, QueryImpleme
return uniqueResult();
}
@Override
ProcedureCallImplementor<R> registerStoredProcedureParameter(int position, BasicTypeReference<?> type, ParameterMode mode);
@Override
ProcedureCallImplementor<R> registerStoredProcedureParameter(String parameterName, BasicTypeReference<?> type, ParameterMode mode);
@Override
ProcedureCallImplementor<R> setHint(String hintName, Object value);
@ -71,4 +78,5 @@ public interface ProcedureCallImplementor<R> extends ProcedureCall, QueryImpleme
@Override
ProcedureCallImplementor<R> registerStoredProcedureParameter(String parameterName, Class type, ParameterMode mode);
}

View File

@ -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" );

View File

@ -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<T> implements QueryParameterBinding<T>, 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<T> implements QueryParameterBinding<T>, 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;
}

View File

@ -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

View File

@ -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
)
);
}
,

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<BigDecimal> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<BigInteger> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<byte[]>
implements AdjustableBasicType<byte[]> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Blob> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Boolean>
implements AdjustableBasicType<Boolean> {
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<Boolean> javaTypeDescriptor) {
super( jdbcType, javaTypeDescriptor );
}
@Override
public String getName() {
return "boolean";
}
@Override
public String[] getRegistrationKeys() {
return new String[] { getName(), boolean.class.getName(), Boolean.class.getName() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Byte> {
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()};
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Calendar> {
public static final CalendarDateType INSTANCE = new CalendarDateType();
public CalendarDateType() {
super( DateJdbcType.INSTANCE, CalendarDateJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "calendar_date";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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}.
* <p/>
* 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<Calendar> {
public static final CalendarTimeType INSTANCE = new CalendarTimeType();
public CalendarTimeType() {
super( TimeJdbcType.INSTANCE, CalendarTimeJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "calendar_time";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Calendar> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<char[]>
implements AdjustableBasicType<char[]> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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[]}
* <p/>
* 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<Character[]>
implements AdjustableBasicType<Character[]> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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[]}
* <p/>
* 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<Character[]>
implements AdjustableBasicType<Character[]> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Character[]>
implements AdjustableBasicType<Character[]> {
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[]" };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Character> {
public static final CharacterNCharType INSTANCE = new CharacterNCharType();
public CharacterNCharType() {
super( NCharJdbcType.INSTANCE, CharacterJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "ncharacter";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Character>
implements AdjustableBasicType<Character> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Class> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Clob> implements AdjustableBasicType<Clob> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Currency> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Date> {
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()
};
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Double> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Duration> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Float> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<byte[]> {
public static final ImageType INSTANCE = new ImageType();
public ImageType() {
super( LongVarbinaryJdbcType.INSTANCE, PrimitiveByteArrayJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "image";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Instant> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Integer> {
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()};
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<LocalDateTime> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<LocalDate> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<LocalTime> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Locale> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Long> {
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() };
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<byte[]> {
public static final MaterializedBlobType INSTANCE = new MaterializedBlobType();
public MaterializedBlobType() {
super( BlobJdbcType.DEFAULT, PrimitiveByteArrayJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "materialized_blob";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String>
implements AdjustableBasicType<String> {
public static final MaterializedClobType INSTANCE = new MaterializedClobType();
public MaterializedClobType() {
super( ClobJdbcType.DEFAULT, StringJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "materialized_clob";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String> {
public static final MaterializedNClobType INSTANCE = new MaterializedNClobType();
public MaterializedNClobType() {
super( NClobJdbcType.DEFAULT, StringJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "materialized_nclob";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<NClob> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String> {
public static final NTextType INSTANCE = new NTextType();
public NTextType() {
super( LongNVarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "ntext";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Boolean>
implements ConvertedBasicType<Boolean> {
public static final NumericBooleanType INSTANCE = new NumericBooleanType();
public NumericBooleanType() {
super( IntegerJdbcType.INSTANCE, BooleanJavaTypeDescriptor.INSTANCE );
}
@Override
public String getName() {
return "numeric_boolean";
}
@Override
public BasicValueConverter<Boolean, ?> getValueConverter() {
return NumericBooleanConverter.INSTANCE;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<OffsetDateTime> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<OffsetTime> {
/**
* 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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<char[]>
implements AdjustableBasicType<char[]> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<char[]> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Short> {
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()};
}
}

View File

@ -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<OffsetDateTime> 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<OffsetDateTime> 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<ZonedDateTime> 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<ZonedDateTime> 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(

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String>
implements AdjustableBasicType<String> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<String>
implements AdjustableBasicType<String> {
public static final TextType INSTANCE = new TextType();
public TextType() {
super( LongVarcharJdbcType.INSTANCE, StringJavaTypeDescriptor.INSTANCE );
}
public String getName() {
return "text";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Date> {
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;
// }
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<TimeZone> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Boolean>
implements ConvertedBasicType<Boolean> {
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<Boolean, ?> getValueConverter() {
return TrueFalseConverter.INSTANCE;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<UUID> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<UUID> {
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";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<URL> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Byte[]> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Byte[]> implements AdjustableBasicType<Byte[]> {
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";
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<Boolean>
implements ConvertedBasicType<Boolean> {
public static final YesNoType INSTANCE = new YesNoType();
public YesNoType() {
super( CharJdbcType.INSTANCE, BooleanJavaTypeDescriptor.INSTANCE );
}
@Override
public String getName() {
return "yes_no";
}
@Override
public BasicValueConverter<Boolean, ?> getValueConverter() {
return YesNoConverter.INSTANCE;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<ZoneOffset> {
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;
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<ZonedDateTime> {
/**
* 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;
}
}

View File

@ -50,9 +50,8 @@ public class InstantJavaTypeDescriptor extends AbstractTemporalJavaTypeDescripto
@Override
protected <X> TemporalJavaTypeDescriptor<X> forDatePrecision(TypeConfiguration typeConfiguration) {
// todo (6.0) : resolve against the type registry instead?
//noinspection unchecked
return (TemporalJavaTypeDescriptor<X>) JdbcDateJavaTypeDescriptor.INSTANCE;
return (TemporalJavaTypeDescriptor<X>) this;
}
@Override
@ -64,7 +63,7 @@ public class InstantJavaTypeDescriptor extends AbstractTemporalJavaTypeDescripto
@Override
protected <X> TemporalJavaTypeDescriptor<X> forTimePrecision(TypeConfiguration typeConfiguration) {
//noinspection unchecked
return (TemporalJavaTypeDescriptor<X>) JdbcTimeJavaTypeDescriptor.INSTANCE;
return (TemporalJavaTypeDescriptor<X>) 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 ) ) {

View File

@ -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
*/

View File

@ -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

View File

@ -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<SqlAstNode> 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(

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -13,11 +13,11 @@ import java.sql.Clob;
* <p/>
* {@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}
* <p/>
* {@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

View File

@ -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;

View File

@ -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 );

View File

@ -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 );

View File

@ -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" );

View File

@ -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 );
}
);

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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<? extends Dialect> dialectClass,
Class entityClass,
BasicTypeReference<?> binaryTypeClass,
BasicTypeReference<?> charTypeClass) {
check( dialectClass, entityClass, binaryTypeClass, charTypeClass, false );
}
private void check(
Class<? extends Dialect> 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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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
*/

View File

@ -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 );

View File

@ -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;

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More