Get rid of LiteralType

This commit is contained in:
Christian Beikov 2021-10-05 12:03:23 +02:00
parent bfe2da9d4f
commit 81e66fa970
49 changed files with 117 additions and 255 deletions

View File

@ -13,7 +13,6 @@ import java.util.Date;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.LiteralType;
import org.hibernate.type.VersionType;
import org.hibernate.type.descriptor.java.JdbcTimestampTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.BigIntTypeDescriptor;
@ -25,7 +24,7 @@ import org.hibernate.type.descriptor.jdbc.BigIntTypeDescriptor;
public class TimestampEpochType
extends AbstractSingleColumnStandardBasicType<Date>
implements VersionType<Date>, LiteralType<Date> {
implements VersionType<Date> {
public static final TimestampEpochType INSTANCE = new TimestampEpochType();

View File

@ -2,7 +2,6 @@ package org.hibernate.userguide.mapping.basic;
import java.util.BitSet;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -26,12 +25,7 @@ public class BitSetType
return fromString( sequence );
}
@Override
public String objectToSQLString(BitSet value, Dialect dialect) throws Exception {
return toString( value );
}
@Override
@Override
public String getName() {
return "bitset";
}

View File

@ -45,6 +45,7 @@ import org.hibernate.query.sqm.spi.SqmCreationContext;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.spi.TypeConfiguration;
/**
@ -161,6 +162,8 @@ public interface SessionFactoryImplementor
*/
FastSessionServices getFastSessionServices();
WrapperOptions getWrapperOptions();
/**
* Contract for resolving this SessionFactory on deserialization
*/

View File

@ -103,6 +103,7 @@ import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.persister.entity.SessionFactoryBasedWrapperOptions;
import org.hibernate.procedure.spi.ProcedureCallImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.proxy.HibernateProxyHelper;
@ -126,6 +127,7 @@ import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.tool.schema.spi.DelayedDropAction;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.spi.TypeConfiguration;
import org.jboss.logging.Logger;
@ -186,6 +188,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
private final transient Map<String, FetchProfile> fetchProfiles;
private final transient FastSessionServices fastSessionServices;
private final transient WrapperOptions wrapperOptions;
private final transient SessionBuilder defaultSessionOpenOptions;
private final transient SessionBuilder temporarySessionOpenOptions;
private final transient StatelessSessionBuilder defaultStatelessOptions;
@ -372,6 +375,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
this.temporarySessionOpenOptions = this.defaultSessionOpenOptions == null ? null : buildTemporarySessionOpenOptions();
this.defaultStatelessOptions = this.defaultSessionOpenOptions == null ? null : withStatelessOptions();
this.fastSessionServices = new FastSessionServices( this );
this.wrapperOptions = new SessionFactoryBasedWrapperOptions( this );
this.observer.sessionFactoryCreated( this );
@ -1643,6 +1647,11 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
return this.fastSessionServices;
}
@Override
public WrapperOptions getWrapperOptions() {
return wrapperOptions;
}
private enum Status {
OPEN,
CLOSING,

View File

@ -16,7 +16,6 @@ import java.util.Objects;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -226,11 +225,6 @@ public class DiscriminatorType<T> extends AbstractType implements org.hibernate.
return underlyingType.getColumnSpan( mapping );
}
@Override
public String objectToSQLString(T value, Dialect dialect) throws Exception {
return ( (org.hibernate.type.DiscriminatorType<T>) underlyingType ).objectToSQLString( value, dialect );
}
@Override
public T stringToObject(CharSequence sequence) throws Exception {
return ( (org.hibernate.type.DiscriminatorType<T>) underlyingType ).stringToObject( sequence );

View File

@ -69,6 +69,7 @@ import org.hibernate.type.CompositeType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.jboss.logging.Logger;
@ -194,10 +195,12 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
else {
try {
discriminatorValue = discriminatorType.stringToObject( persistentClass.getDiscriminatorValue() );
discriminatorSQLString = ((DiscriminatorType) discriminatorType).objectToSQLString(
discriminatorValue,
factory.getJdbcServices().getDialect()
);
discriminatorSQLString = discriminatorType.getJdbcTypeDescriptor().getJdbcLiteralFormatter( (JavaTypeDescriptor) discriminatorType.getJavaTypeDescriptor() )
.toJdbcLiteral(
discriminatorValue,
factory.getJdbcServices().getDialect(),
factory.getWrapperOptions()
);
}
catch (ClassCastException cce) {
throw new MappingException("Illegal discriminator type: " + discriminatorType.getName() );

View File

@ -0,0 +1,58 @@
/*
* 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.persister.entity;
import java.util.TimeZone;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
/**
*
* @author Christian Beikov
*/
public class SessionFactoryBasedWrapperOptions implements WrapperOptions {
private final SessionFactoryImplementor factory;
public SessionFactoryBasedWrapperOptions(SessionFactoryImplementor factory) {
this.factory = factory;
}
@Override
public SharedSessionContractImplementor getSession() {
throw new UnsupportedOperationException();
}
@Override
public boolean useStreamForLobBinding() {
return factory.getFastSessionServices().useStreamForLobBinding();
}
@Override
public int getPreferredSqlTypeCodeForBoolean() {
return factory.getFastSessionServices().getPreferredSqlTypeCodeForBoolean();
}
@Override
public LobCreator getLobCreator() {
return factory.getJdbcServices().getLobCreator( getSession() );
}
@Override
public JdbcTypeDescriptor remapSqlTypeDescriptor(JdbcTypeDescriptor jdbcTypeDescriptor) {
return jdbcTypeDescriptor;
}
@Override
public TimeZone getJdbcTimeZone() {
return factory.getSessionFactoryOptions().getJdbcTimeZone();
}
}

View File

@ -63,6 +63,7 @@ import org.hibernate.type.AssociationType;
import org.hibernate.type.BasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* The default implementation of the <tt>EntityPersister</tt> interface.
@ -340,8 +341,12 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
discriminatorInsertable = persistentClass.isDiscriminatorInsertable() && !discrimValue.hasFormula();
try {
discriminatorValue = discriminatorType.stringToObject( persistentClass.getDiscriminatorValue() );
discriminatorSQLValue = ((DiscriminatorType) discriminatorType)
.objectToSQLString( discriminatorValue, dialect );
discriminatorSQLValue = discriminatorType.getJdbcTypeDescriptor().getJdbcLiteralFormatter( (JavaTypeDescriptor) discriminatorType.getJavaTypeDescriptor() )
.toJdbcLiteral(
discriminatorValue,
factory.getJdbcServices().getDialect(),
factory.getWrapperOptions()
);
}
catch (ClassCastException cce) {
throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() );

View File

@ -11,7 +11,6 @@ import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
/**
* An SQL <tt>INSERT</tt> statement
@ -74,10 +73,6 @@ public class Insert {
return this;
}
public Insert addColumn(String columnName, Object value, LiteralType type) throws Exception {
return addColumn( columnName, type.objectToSQLString( value, dialect ) );
}
public Insert addIdentityColumn(String columnName) {
String value = dialect.getIdentityColumnSupport().getIdentityInsertString();
if ( value != null ) {

View File

@ -10,7 +10,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.LiteralType;
/**
* An SQL <tt>UPDATE</tt> statement
@ -131,10 +130,6 @@ public class Update {
return this;
}
public Update addColumn(String columnName, Object value, LiteralType type) throws Exception {
return addColumn( columnName, type.objectToSQLString(value, dialect) );
}
public Update addWhereColumns(String[] columnNames) {
for ( String columnName : columnNames ) {
addWhereColumn( columnName );

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.math.BigInteger;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.BigIntegerTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.NumericTypeDescriptor;
@ -38,11 +37,6 @@ public class BigIntegerType
return true;
}
@Override
public String objectToSQLString(BigInteger value, Dialect dialect) {
return BigIntegerTypeDescriptor.INSTANCE.toString( value );
}
@Override
public BigInteger stringToObject(CharSequence string) {
return BigIntegerTypeDescriptor.INSTANCE.fromString( string );

View File

@ -10,11 +10,9 @@ import java.io.Serializable;
import java.sql.Types;
import org.hibernate.Incubating;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptorIndicators;
/**
* A type that maps between {@link Types#BOOLEAN BOOLEAN} and {@link Boolean}
@ -62,9 +60,4 @@ public class BooleanType
return fromString( string );
}
@Override
public String objectToSQLString(Boolean value, Dialect dialect) {
return dialect.toBooleanValueString( value );
}
}

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import java.util.Comparator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.ByteTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.TinyIntTypeDescriptor;
@ -52,11 +51,6 @@ public class ByteType
return byte.class;
}
@Override
public String objectToSQLString(Byte value, Dialect dialect) {
return toString( value );
}
@Override
public Byte stringToObject(CharSequence sequence) {
return fromString( sequence );

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.CharacterTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.NCharTypeDescriptor;
@ -40,16 +39,6 @@ public class CharacterNCharType
return char.class;
}
public String objectToSQLString(Character value, Dialect dialect) {
if ( value == '\'' ) {
return "''''";
}
final char[] chars = new char[3];
chars[0] = chars[2] = '\'';
chars[1] = value;
return new String( chars );
}
public Character stringToObject(CharSequence sequence) {
return fromString( sequence );
}

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import java.sql.Types;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.CharacterTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.CharTypeDescriptor;
@ -46,16 +45,6 @@ public class CharacterType
return char.class;
}
public String objectToSQLString(Character value, Dialect dialect) {
if ( value == '\'' ) {
return "''''";
}
final char[] chars = new char[3];
chars[0] = chars[2] = '\'';
chars[1] = value;
return new String( chars );
}
public Character stringToObject(CharSequence sequence) {
return fromString( sequence );
}

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.util.Currency;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.CurrencyTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -19,8 +18,7 @@ import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
* @author Steve Ebersole
*/
public class CurrencyType
extends AbstractSingleColumnStandardBasicType<Currency>
implements LiteralType<Currency> {
extends AbstractSingleColumnStandardBasicType<Currency> {
public static final CurrencyType INSTANCE = new CurrencyType();
@ -37,7 +35,4 @@ public class CurrencyType
return true;
}
public String objectToSQLString(Currency value, Dialect dialect) throws Exception {
return "'" + toString( value ) + "'";
}
}

View File

@ -17,7 +17,6 @@ import java.util.Map;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -256,11 +255,6 @@ public class CustomType
return fromStringValue( sequence );
}
@Override
public String objectToSQLString(Object value, Dialect dialect) throws Exception {
return ( (EnhancedUserType) getUserType() ).objectToSQLString( value);
}
@Override
public Comparator getComparator() {
return (Comparator) getUserType();

View File

@ -11,7 +11,6 @@ import java.util.Date;
import jakarta.persistence.TemporalType;
import org.hibernate.QueryException;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.model.domain.AllowableTemporalParameterType;
import org.hibernate.type.descriptor.java.JdbcDateTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
@ -24,7 +23,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class DateType
extends AbstractSingleColumnStandardBasicType<Date>
implements IdentifierType<Date>, LiteralType<Date>, AllowableTemporalParameterType<Date> {
implements IdentifierType<Date>, AllowableTemporalParameterType<Date> {
public static final DateType INSTANCE = new DateType();
@ -49,14 +48,6 @@ public class DateType
// return true;
// }
public String objectToSQLString(Date value, Dialect dialect) throws Exception {
final java.sql.Date jdbcDate = java.sql.Date.class.isInstance( value )
? ( java.sql.Date ) value
: new java.sql.Date( value.getTime() );
// TODO : use JDBC date literal escape syntax? -> {d 'date-string'} in yyyy-mm-dd format
return StringType.INSTANCE.objectToSQLString( jdbcDate.toString(), dialect );
}
public Date stringToObject(CharSequence sequence) {
return fromString( sequence );
}

View File

@ -7,7 +7,8 @@
package org.hibernate.type;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.JdbcTypeDescriptor;
/**
* Additional contract for a {@link Type} may be used for a discriminator.
@ -15,16 +16,17 @@ import org.hibernate.dialect.Dialect;
* @author Gavin King
* @author Steve Ebersole
*/
public interface DiscriminatorType<T> extends IdentifierType<T>, LiteralType<T> {
public interface DiscriminatorType<T> extends IdentifierType<T> {
/**
* Render the given discriminator value to a literal format
* for embedding in the generated SQL.
*
* @param value The value to convert
* @param dialect The SQL dialect
*
* @return The value's SQL literal representation
* The descriptor for the Java type represented by this
* expressable type
*/
@Override
String objectToSQLString(T value, Dialect dialect) throws Exception;
JavaTypeDescriptor<T> getJavaTypeDescriptor();
/**
* The descriptor for the SQL type represented by this
* expressable type
*/
JdbcTypeDescriptor getJdbcTypeDescriptor();
}

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.DoubleTypeDescriptor;
/**
@ -44,8 +43,4 @@ public class DoubleType
public Class getPrimitiveClass() {
return double.class;
}
@Override
public String objectToSQLString(Double value, Dialect dialect) throws Exception {
return toString( value );
}
}

View File

@ -15,8 +15,7 @@ import org.hibernate.type.descriptor.jdbc.NumericTypeDescriptor;
* @author Steve Ebersole
*/
public class DurationType
extends AbstractSingleColumnStandardBasicType<Duration>
implements LiteralType<Duration> {
extends AbstractSingleColumnStandardBasicType<Duration> {
/**
* Singleton access
*/

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.FloatTypeDescriptor;
/**
@ -42,8 +41,4 @@ public class FloatType extends AbstractSingleColumnStandardBasicType<Float> impl
public Class getPrimitiveClass() {
return float.class;
}
@Override
public String objectToSQLString(Float value, Dialect dialect) throws Exception {
return toString( value );
}
}

View File

@ -27,7 +27,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class InstantType
extends AbstractSingleColumnStandardBasicType<Instant>
implements VersionType<Instant>, LiteralType<Instant>, AllowableTemporalParameterType<Instant> {
implements VersionType<Instant>, AllowableTemporalParameterType<Instant> {
/**
* Singleton access
*/

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import java.util.Comparator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.IntegerTypeDescriptor;
@ -50,11 +49,6 @@ public class IntegerType extends AbstractSingleColumnStandardBasicType<Integer>
return int.class;
}
@Override
public String objectToSQLString(Integer value, Dialect dialect) throws Exception {
return toString( value );
}
@Override
public Integer stringToObject(CharSequence sequence) {
return fromString( sequence );

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.AssertionFailure;
import org.hibernate.dialect.Dialect;
/**
* Additional contract for a {@link Type} that may appear as an SQL literal
*
* @author Gavin King
* @author Steve Ebersole
*
* @deprecated (since 6.0) Use {@link org.hibernate.query.hql.LiteralConsumer}
* mechanism instead
*/
@Deprecated
public interface LiteralType<T> {
/**
* Convert the value into a string representation, suitable for embedding in an SQL statement as a
* literal.
*
* @param value The value to convert
* @param dialect The SQL dialect
*
* @return The value's string representation
*
* @throws Exception Indicates an issue converting the value to literal string.
*/
default String objectToSQLString(T value, Dialect dialect) throws Exception {
throw new AssertionFailure("not a discriminator type");
}
}

View File

@ -25,7 +25,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class LocalDateTimeType
extends AbstractSingleColumnStandardBasicType<LocalDateTime>
implements VersionType<LocalDateTime>, LiteralType<LocalDateTime>, AllowableTemporalParameterType<LocalDateTime> {
implements VersionType<LocalDateTime>, AllowableTemporalParameterType<LocalDateTime> {
/**
* Singleton access
*/

View File

@ -20,7 +20,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class LocalDateType
extends AbstractSingleColumnStandardBasicType<LocalDate>
implements LiteralType<LocalDate>, AllowableTemporalParameterType<LocalDate> {
implements AllowableTemporalParameterType<LocalDate> {
/**
* Singleton access

View File

@ -21,7 +21,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class LocalTimeType
extends AbstractSingleColumnStandardBasicType<LocalTime>
implements LiteralType<LocalTime>, AllowableTemporalParameterType<LocalTime> {
implements AllowableTemporalParameterType<LocalTime> {
/**
* Singleton access
*/

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.util.Locale;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.LocaleTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -18,8 +17,7 @@ import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
* @author Gavin King
* @author Steve Ebersole
*/
public class LocaleType extends AbstractSingleColumnStandardBasicType<Locale>
implements LiteralType<Locale> {
public class LocaleType extends AbstractSingleColumnStandardBasicType<Locale> {
public static final LocaleType INSTANCE = new LocaleType();
@ -36,7 +34,4 @@ public class LocaleType extends AbstractSingleColumnStandardBasicType<Locale>
return true;
}
public String objectToSQLString(Locale value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( toString( value ), dialect );
}
}

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import java.util.Comparator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.LongTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.BigIntTypeDescriptor;
@ -72,8 +71,4 @@ public class LongType
return getJavaTypeDescriptor().getComparator();
}
@Override
public String objectToSQLString(Long value, Dialect dialect) throws Exception {
return value.toString();
}
}

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.query.CastType;
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
@ -46,10 +45,7 @@ public class NumericBooleanType
public Boolean stringToObject(CharSequence string) {
return fromString( string );
}
@Override
public String objectToSQLString(Boolean value, Dialect dialect) {
return value ? "1" : "0";
}
@Override
public CastType getCastType() {
return CastType.INTEGER_BOOLEAN;

View File

@ -24,7 +24,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class OffsetDateTimeType
extends AbstractSingleColumnStandardBasicType<OffsetDateTime>
implements VersionType<OffsetDateTime>, LiteralType<OffsetDateTime>, AllowableTemporalParameterType<OffsetDateTime> {
implements VersionType<OffsetDateTime>, AllowableTemporalParameterType<OffsetDateTime> {
/**
* Singleton access

View File

@ -20,7 +20,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class OffsetTimeType
extends AbstractSingleColumnStandardBasicType<OffsetTime>
implements LiteralType<OffsetTime>, AllowableTemporalParameterType<OffsetTime> {
implements AllowableTemporalParameterType<OffsetTime> {
/**
* Singleton access

View File

@ -12,7 +12,7 @@ package org.hibernate.type;
* @author Gavin King
* @author Steve Ebersole
*/
public interface PrimitiveType<T> extends LiteralType<T>, AdjustableBasicType<T> {
public interface PrimitiveType<T> extends AdjustableBasicType<T> {
/**
* Retrieve the primitive counterpart to the wrapper type identified by
* {@link Type#getReturnedClass()}.

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import java.util.Comparator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.type.descriptor.java.ShortTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.SmallIntTypeDescriptor;
@ -52,11 +51,6 @@ public class ShortType
return short.class;
}
@Override
public String objectToSQLString(Short value, Dialect dialect) {
return value.toString();
}
@Override
public Short stringToObject(CharSequence sequence) {
return Short.valueOf( sequence.toString() );

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.type;
import org.hibernate.dialect.Dialect;
import org.hibernate.query.internal.QueryLiteralHelper;
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.NVarcharTypeDescriptor;
@ -36,10 +34,6 @@ public class StringNVarcharType
return false;
}
public String objectToSQLString(String value, Dialect dialect) throws Exception {
return QueryLiteralHelper.toStringLiteral( value );
}
public String stringToObject(CharSequence sequence) throws Exception {
return sequence.toString();
}

View File

@ -8,8 +8,6 @@ package org.hibernate.type;
import java.sql.Types;
import org.hibernate.dialect.Dialect;
import org.hibernate.query.internal.QueryLiteralHelper;
import org.hibernate.type.descriptor.java.StringTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -38,10 +36,6 @@ public class StringType
return true;
}
public String objectToSQLString(String value, Dialect dialect) throws Exception {
return QueryLiteralHelper.toStringLiteral( value );
}
public String stringToObject(CharSequence sequence) throws Exception {
return sequence.toString();
}

View File

@ -23,7 +23,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class TimeType
extends AbstractSingleColumnStandardBasicType<Date>
implements LiteralType<Date>, AllowableTemporalParameterType<Date> {
implements AllowableTemporalParameterType<Date> {
public static final TimeType INSTANCE = new TimeType();

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.util.TimeZone;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.TimeZoneTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -19,8 +18,7 @@ import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
* @author Steve Ebersole
*/
public class TimeZoneType
extends AbstractSingleColumnStandardBasicType<TimeZone>
implements LiteralType<TimeZone> {
extends AbstractSingleColumnStandardBasicType<TimeZone> {
public static final TimeZoneType INSTANCE = new TimeZoneType();
@ -37,8 +35,4 @@ public class TimeZoneType
return true;
}
public String objectToSQLString(TimeZone value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value.getID(), dialect );
}
}

View File

@ -27,7 +27,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class TimestampType
extends AbstractSingleColumnStandardBasicType<Date>
implements VersionType<Date>, LiteralType<Date>, AllowableTemporalParameterType<Date> {
implements VersionType<Date>, AllowableTemporalParameterType<Date> {
public static final TimestampType INSTANCE = new TimestampType();

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.query.CastType;
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
@ -53,11 +52,6 @@ public class TrueFalseType
return Boolean.FALSE;
}
@Override
public String objectToSQLString(Boolean value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value ? "T" : "F", dialect );
}
@Override
public CastType getCastType() {
return CastType.TF_BOOLEAN;

View File

@ -17,7 +17,7 @@ import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
*
* @author Steve Ebersole
*/
public class UUIDCharType extends AbstractSingleColumnStandardBasicType<UUID> implements LiteralType<UUID> {
public class UUIDCharType extends AbstractSingleColumnStandardBasicType<UUID> {
public static final UUIDCharType INSTANCE = new UUIDCharType();
public UUIDCharType() {
@ -33,7 +33,4 @@ public class UUIDCharType extends AbstractSingleColumnStandardBasicType<UUID> im
return "uuid-char";
}
public String objectToSQLString(UUID value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value.toString(), dialect );
}
}

View File

@ -8,7 +8,6 @@ package org.hibernate.type;
import java.net.URL;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.UrlTypeDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -38,10 +37,6 @@ public class UrlType extends AbstractSingleColumnStandardBasicType<URL> implemen
return UrlTypeDescriptor.INSTANCE.toString( value );
}
public String objectToSQLString(URL value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( toString( value ), dialect );
}
public URL stringToObject(CharSequence sequence) throws Exception {
return UrlTypeDescriptor.INSTANCE.fromString( sequence );
}

View File

@ -9,7 +9,6 @@ package org.hibernate.type;
import java.io.Serializable;
import org.hibernate.Internal;
import org.hibernate.dialect.Dialect;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.query.CastType;
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
@ -54,11 +53,6 @@ public class YesNoType
return Boolean.FALSE;
}
@Override
public String objectToSQLString(Boolean value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value ? "Y" : "N", dialect );
}
@Override
public CastType getCastType() {
return CastType.YN_BOOLEAN;

View File

@ -6,7 +6,6 @@
*/
package org.hibernate.type;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.descriptor.java.ZoneOffsetJavaDescriptor;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -19,8 +18,7 @@ import java.time.ZoneOffset;
* @author Steve Ebersole
*/
public class ZoneOffsetType
extends AbstractSingleColumnStandardBasicType<ZoneOffset>
implements LiteralType<ZoneOffset> {
extends AbstractSingleColumnStandardBasicType<ZoneOffset> {
public static final ZoneOffsetType INSTANCE = new ZoneOffsetType();
@ -37,8 +35,4 @@ public class ZoneOffsetType
return true;
}
public String objectToSQLString(ZoneOffset value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value.getId(), dialect );
}
}

View File

@ -24,7 +24,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class ZonedDateTimeType
extends AbstractSingleColumnStandardBasicType<ZonedDateTime>
implements VersionType<ZonedDateTime>, LiteralType<ZonedDateTime>, AllowableTemporalParameterType<ZonedDateTime> {
implements VersionType<ZonedDateTime>, AllowableTemporalParameterType<ZonedDateTime> {
/**
* Singleton access

View File

@ -2,7 +2,6 @@ package org.hibernate.orm.test.type.contributor;
import java.util.Map;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.descriptor.jdbc.VarcharTypeDescriptor;
@ -33,11 +32,6 @@ public class ArrayType
return fromString( sequence );
}
@Override
public String objectToSQLString(Array value, Dialect dialect) throws Exception {
return toString( value );
}
@Override
public String getName() {
return "comma-separated-array";

View File

@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import org.hibernate.AssertionFailure;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.StringType;
@ -103,10 +102,6 @@ public class StoredPrefixedStringType
return true;
}
public String objectToSQLString(String value, Dialect dialect) throws Exception {
return StringType.INSTANCE.objectToSQLString( value, dialect );
}
public String stringToObject(CharSequence sequence) throws Exception {
return StringType.INSTANCE.stringToObject( sequence );
}

View File

@ -12,7 +12,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import org.hibernate.dialect.Dialect;
import org.hibernate.type.BooleanType;
class SDOBooleanType extends BooleanType {
@ -51,8 +50,4 @@ class SDOBooleanType extends BooleanType {
}
}
public String objectToSQLString(Boolean value, Dialect dialect) {
return value ? "'TRUE'" : "'FALSE'";
}
}