extract an oft-repeated expression as a new method of JdbcTypeIndicators

write some Javadoc about types
This commit is contained in:
Gavin 2022-11-12 19:45:41 +01:00 committed by Gavin King
parent 77a1be10b1
commit dbc7b2359b
49 changed files with 488 additions and 259 deletions

View File

@ -100,7 +100,7 @@ public class PostgreSQLIntervalSecondJdbcType implements AdjustableJdbcType {
public JdbcType resolveIndicatedType(JdbcTypeIndicators indicators, JavaType<?> domainJtd) {
// The default scale is 9
if ( indicators.getColumnScale() == JdbcTypeIndicators.NO_COLUMN_SCALE || indicators.getColumnScale() > 6 ) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.NUMERIC );
return indicators.getJdbcType( SqlTypes.NUMERIC );
}
return this;
}

View File

@ -47,6 +47,6 @@ public interface EntityRepresentationStrategy extends ManagedTypeRepresentationS
}
default void visitEntityNameResolvers(Consumer<EntityNameResolver> consumer) {
// byt default do nothing
// by default do nothing
}
}

View File

@ -32,7 +32,8 @@ import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
import org.hibernate.type.descriptor.jdbc.JdbcType;
/**
* Convenience base class for {@link BasicType} implementations
* Convenience base class for {@link BasicType} implementations.
* Packages a {@link JavaType} with a {@link JdbcType}.
*
* @author Steve Ebersole
* @author Brett Meyer

View File

@ -12,9 +12,9 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* Extension contract for BasicType implementations that understand how to
* adjust themselves relative to where/how they are used (e.g. accounting
* for LOB, nationalized, primitive/wrapper, etc).
* Extension contract for {@link BasicType} implementations which understand how to
* adjust themselves relative to where/how they're used by, for example, accounting
* for LOB, nationalized, primitive/wrapper, etc.
*/
public interface AdjustableBasicType<J> extends BasicType<J> {
/**

View File

@ -41,6 +41,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code TINYINT}.
*
* @see Types#TINYINT
* @see org.hibernate.type.descriptor.jdbc.TinyIntJdbcType
*/
public final static int TINYINT = Types.TINYINT;
@ -48,6 +49,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code SMALLINT}.
*
* @see Types#SMALLINT
* @see org.hibernate.type.descriptor.jdbc.SmallIntJdbcType
*/
public final static int SMALLINT = Types.SMALLINT;
@ -55,6 +57,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code INTEGER}.
*
* @see Types#INTEGER
* @see org.hibernate.type.descriptor.jdbc.IntegerJdbcType
*/
public final static int INTEGER = Types.INTEGER;
@ -62,6 +65,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code BIGINT}.
*
* @see Types#BIGINT
* @see org.hibernate.type.descriptor.jdbc.BigIntJdbcType
*/
public final static int BIGINT = Types.BIGINT;
@ -69,6 +73,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code FLOAT}.
*
* @see Types#FLOAT
* @see org.hibernate.type.descriptor.jdbc.FloatJdbcType
*/
public final static int FLOAT = Types.FLOAT;
@ -76,14 +81,15 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code REAL}.
*
* @see Types#REAL
* @see org.hibernate.type.descriptor.jdbc.RealJdbcType
*/
public final static int REAL = Types.REAL;
/**
* A type code representing the generic SQL type {@code DOUBLE}.
*
* @see Types#DOUBLE
* @see org.hibernate.type.descriptor.jdbc.DoubleJdbcType
*/
public final static int DOUBLE = Types.DOUBLE;
@ -91,6 +97,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code NUMERIC}.
*
* @see Types#NUMERIC
* @see org.hibernate.type.descriptor.jdbc.NumericJdbcType
*/
public final static int NUMERIC = Types.NUMERIC;
@ -98,6 +105,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code DECIMAL}.
*
* @see Types#DECIMAL
* @see org.hibernate.type.descriptor.jdbc.DecimalJdbcType
*/
public final static int DECIMAL = Types.DECIMAL;
@ -105,6 +113,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code CHAR}.
*
* @see Types#CHAR
* @see org.hibernate.type.descriptor.jdbc.CharJdbcType
*/
public final static int CHAR = Types.CHAR;
@ -112,6 +121,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code VARCHAR}.
*
* @see Types#VARCHAR
* @see org.hibernate.type.descriptor.jdbc.VarcharJdbcType
*/
public final static int VARCHAR = Types.VARCHAR;
@ -124,6 +134,7 @@ public class SqlTypes {
* @see org.hibernate.Length#LONG
*
* @see Types#LONGVARCHAR
* @see org.hibernate.type.descriptor.jdbc.LongVarcharJdbcType
*/
public final static int LONGVARCHAR = Types.LONGVARCHAR;
@ -140,6 +151,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code DATE}.
*
* @see Types#DATE
* @see org.hibernate.type.descriptor.jdbc.DateJdbcType
*/
public final static int DATE = Types.DATE;
@ -147,6 +159,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code TIME}.
*
* @see Types#TIME
* @see org.hibernate.type.descriptor.jdbc.TimeJdbcType
*/
public final static int TIME = Types.TIME;
@ -154,6 +167,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code TIMESTAMP}.
*
* @see Types#TIMESTAMP
* @see org.hibernate.type.descriptor.jdbc.TimestampJdbcType
*/
public final static int TIMESTAMP = Types.TIMESTAMP;
@ -161,6 +175,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code BINARY}.
*
* @see Types#BINARY
* @see org.hibernate.type.descriptor.jdbc.BinaryJdbcType
*/
public final static int BINARY = Types.BINARY;
@ -168,6 +183,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code VARBINARY}.
*
* @see Types#VARBINARY
* @see org.hibernate.type.descriptor.jdbc.VarbinaryJdbcType
*/
public final static int VARBINARY = Types.VARBINARY;
@ -180,6 +196,7 @@ public class SqlTypes {
* @see org.hibernate.Length#LONG
*
* @see Types#LONGVARBINARY
* @see org.hibernate.type.descriptor.jdbc.LongVarbinaryJdbcType
*/
public final static int LONGVARBINARY = Types.LONGVARBINARY;
@ -213,6 +230,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code JAVA_OBJECT}.
*
* @see Types#JAVA_OBJECT
* @see org.hibernate.type.descriptor.jdbc.ObjectJdbcType
*/
public final static int JAVA_OBJECT = Types.JAVA_OBJECT;
@ -234,13 +252,15 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code ARRAY}.
*
* @see Types#ARRAY
* @see org.hibernate.type.descriptor.jdbc.ArrayJdbcType
*/
public final static int ARRAY = Types.ARRAY;
/**
* A type code representing the generic SQL type {@code BLOB}.
*
* @see Types#ARRAY
* @see Types#BLOB
* @see org.hibernate.type.descriptor.jdbc.BlobJdbcType
*/
public final static int BLOB = Types.BLOB;
@ -248,6 +268,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code CLOB}.
*
* @see Types#CLOB
* @see org.hibernate.type.descriptor.jdbc.ClobJdbcType
*/
public final static int CLOB = Types.CLOB;
@ -269,6 +290,8 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code BOOLEAN}.
*
* @see Types#BOOLEAN
* @see org.hibernate.cfg.AvailableSettings#PREFERRED_BOOLEAN_JDBC_TYPE
* @see org.hibernate.type.descriptor.jdbc.BooleanJdbcType
*/
public final static int BOOLEAN = Types.BOOLEAN;
@ -283,6 +306,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code NCHAR}.
*
* @see Types#NCHAR
* @see org.hibernate.type.descriptor.jdbc.NCharJdbcType
*/
public static final int NCHAR = Types.NCHAR;
@ -290,6 +314,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code NVARCHAR}.
*
* @see Types#NVARCHAR
* @see org.hibernate.type.descriptor.jdbc.NVarcharJdbcType
*/
public static final int NVARCHAR = Types.NVARCHAR;
@ -302,6 +327,7 @@ public class SqlTypes {
* @see org.hibernate.Length#LONG
*
* @see Types#LONGNVARCHAR
* @see org.hibernate.type.descriptor.jdbc.LongNVarcharJdbcType
*/
public static final int LONGNVARCHAR = Types.LONGNVARCHAR;
@ -318,6 +344,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code NCLOB}.
*
* @see Types#NCLOB
* @see org.hibernate.type.descriptor.jdbc.NClobJdbcType
*/
public static final int NCLOB = Types.NCLOB;
@ -325,6 +352,7 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code XML}.
*
* @see Types#SQLXML
* @see org.hibernate.type.descriptor.jdbc.XmlJdbcType
*/
public static final int SQLXML = Types.SQLXML;
@ -348,6 +376,7 @@ public class SqlTypes {
* {@code TIMESTAMP WITH TIMEZONE}.
*
* @see Types#TIMESTAMP_WITH_TIMEZONE
* @see org.hibernate.type.descriptor.jdbc.TimestampWithTimeZoneJdbcType
*/
public static final int TIMESTAMP_WITH_TIMEZONE = Types.TIMESTAMP_WITH_TIMEZONE;
@ -357,17 +386,22 @@ public class SqlTypes {
* A type code representing the generic SQL type {@code UUID}.
*
* @see org.hibernate.cfg.AvailableSettings#PREFERRED_UUID_JDBC_TYPE
* @see org.hibernate.type.descriptor.jdbc.UUIDJdbcType
*/
public static final int UUID = 3000;
/**
* A type code representing the generic SQL type {@code JSON}.
*
* @see org.hibernate.type.descriptor.jdbc.JsonJdbcType
*/
public static final int JSON = 3001;
/**
* A type code representing the generic SQL type {@code INET} for IPv4
* or IPv6 addresses.
*
* @see org.hibernate.dialect.PostgreSQLInetJdbcType
*/
public static final int INET = 3002;
@ -376,6 +410,11 @@ public class SqlTypes {
* where the value is given in UTC, instead of in the system or
* {@linkplain org.hibernate.cfg.AvailableSettings#JDBC_TIME_ZONE
* JDBC} timezone.
*
* @see org.hibernate.cfg.AvailableSettings#PREFERRED_INSTANT_JDBC_TYPE
* @see org.hibernate.type.descriptor.jdbc.InstantJdbcType
* @see org.hibernate.type.descriptor.jdbc.InstantAsTimestampJdbcType
* @see org.hibernate.type.descriptor.jdbc.InstantAsTimestampWithTimeZoneJdbcType
*/
public static final int TIMESTAMP_UTC = 3003;
@ -384,6 +423,10 @@ public class SqlTypes {
/**
* A type code representing the generic SQL type {@code INTERVAL SECOND}
* for a temporal duration given terms of seconds and fractional seconds.
*
* @see org.hibernate.cfg.AvailableSettings#PREFERRED_DURATION_JDBC_TYPE
* @see org.hibernate.dialect.PostgreSQLIntervalSecondJdbcType
* @see org.hibernate.dialect.H2DurationIntervalSecondJdbcType
*/
public static final int INTERVAL_SECOND = 3100;

View File

@ -19,16 +19,18 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
/**
* Defines a mapping between a Java type and one or more JDBC {@linkplain java.sql.Types types}, as well
* as describing the in-memory semantics of the given java type (how do we check it for 'dirtiness', how do
* we copy values, etc).
* <p/>
* Application developers needing custom types can implement this interface (either directly or via subclassing an
* existing impl) or by the (slightly more stable, though more limited) {@link org.hibernate.usertype.UserType}
* interface.
* <p/>
* Implementations of this interface must certainly be thread-safe. It is recommended that they be immutable as
* well, though that is difficult to achieve completely given the no-arg constructor requirement for custom types.
* Defines a mapping between a Java type and one or more JDBC {@linkplain java.sql.Types types},
* as well as describing the in-memory semantics of the given Java type, including:
* <ul>
* <li>how to compare values and check for "dirtiness",
* <li>how to clone values, and
* <li>how to assemble/disassemble values for storage in the second-level cache.
* </ul>
* An application-defined custom types could, in principle, implement this interface directly,
* but it's safer to implement the more stable interface {@link org.hibernate.usertype.UserType}.
* <p>
* An implementation of this interface must certainly be thread-safe. Ideally, it should also be
* immutable.
*
* @author Gavin King
* @author Steve Ebersole
@ -36,58 +38,62 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
@Internal
public interface Type extends Serializable {
/**
* Return true if the implementation is castable to {@link AssociationType}. This does not necessarily imply that
* the type actually represents an association. Essentially a polymorphic version of
* {@code (type instanceof AssociationType.class)}
* Return true if the implementation is castable to {@link AssociationType}. This does not
* necessarily imply that the type actually represents an association. Shortcut for
* {@code type instanceof AssociationType}.
*
* @return True if this type is also an {@link AssociationType} implementor; false otherwise.
*/
boolean isAssociationType();
/**
* Return true if the implementation is castable to {@link CollectionType}. Essentially a polymorphic version of
* {@code (type instanceof CollectionType.class)}
* Return true if the implementation is castable to {@link CollectionType}. Shortcut for
* {@code type instanceof CollectionType}
* <p/>
* A {@link CollectionType} is additionally an {@link AssociationType}; so if this method returns true,
* {@link #isAssociationType()} should also return true.
* A {@link CollectionType} is additionally an {@link AssociationType}; so if this method
* returns true, {@link #isAssociationType()} should also return true.
*
* @return True if this type is also a {@link CollectionType} implementor; false otherwise.
*/
boolean isCollectionType();
/**
* Return true if the implementation is castable to {@link EntityType}. Essentially a polymorphic
* version of {@code (type instanceof EntityType.class)}.
* Return true if the implementation is castable to {@link EntityType}. Shortcut for
* {@code type instanceof EntityType}.
* <p/>
* An {@link EntityType} is additionally an {@link AssociationType}; so if this method returns true,
* {@link #isAssociationType()} should also return true.
* An {@link EntityType} is additionally an {@link AssociationType}; so if this method
* returns true, {@link #isAssociationType()} should also return true.
*
* @return True if this type is also an {@link EntityType} implementor; false otherwise.
*/
boolean isEntityType();
/**
* Return true if the implementation is castable to {@link AnyType}. Essentially a polymorphic
* version of {@code (type instanceof AnyType.class)}.
* Return true if the implementation is castable to {@link AnyType}. Shortcut for
* {@code type instanceof AnyType}.
* <p/>
* An {@link AnyType} is additionally an {@link AssociationType}; so if this method returns true,
* {@link #isAssociationType()} should also return true.
* An {@link AnyType} is additionally an {@link AssociationType}; so if this method
* returns true, then {@link #isAssociationType()} should also return true.
*
* @return True if this type is also an {@link AnyType} implementor; false otherwise.
*/
boolean isAnyType();
/**
* Return true if the implementation is castable to {@link CompositeType}. Essentially a polymorphic
* version of {@code (type instanceof CompositeType.class)}. A component type may own collections or
* associations and hence must provide certain extra functionality.
* Return true if the implementation is castable to {@link CompositeType}. Shortcut for
* {@code type instanceof CompositeType}.
* <p>
* A component type may own collections or associations and hence must provide certain
* extra functionality.
*
* @return True if this type is also a {@link CompositeType} implementor; false otherwise.
*/
boolean isComponentType();
/**
* How many columns are used to persist this type. Always the same as {@code sqlTypes(mapping).length}
* How many columns are used to persist this type?
* <p>
* Always the same as {@link #getSqlTypeCodes(Mapping) getSqlTypCodes(mapping).length}.
*
* @param mapping The mapping object :/
*
@ -98,9 +104,10 @@ public interface Type extends Serializable {
int getColumnSpan(Mapping mapping) throws MappingException;
/**
* Return the JDBC types codes (per {@link java.sql.Types}) for the columns mapped by this type.
* Return the JDBC types codes as defined by {@link java.sql.Types} or {@link SqlTypes}
* for the columns mapped by this type.
* <p/>
* NOTE: The number of elements in this array matches the return from {@link #getColumnSpan}.
* The number of elements in this array must match the return from {@link #getColumnSpan}.
*
* @param mapping The mapping object :/
*
@ -118,11 +125,13 @@ public interface Type extends Serializable {
Class<?> getReturnedClass();
/**
* Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
* state) taking a shortcut for entity references.
* Compare two instances of the class mapped by this type for persistence "equality",
* that is, equality of persistent state, taking a shortcut for entity references.
* <p/>
* For most types this should equate to an {@link Object#equals equals} check on the values. For associations
* the implication is a bit different. For most types it is conceivable to simply delegate to {@link #isEqual}
* For most types this should boil down to an {@linkplain Object#equals equality}
* comparison of the given values, and it's reasonable to simply delegate to
* {@link #isEqual(Object, Object)}. But for associations the semantics are a bit
* different.
*
* @param x The first value
* @param y The second value
@ -134,12 +143,14 @@ public interface Type extends Serializable {
boolean isSame(Object x, Object y) throws HibernateException;
/**
* Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
* state).
* <p/>
* This should always equate to some form of comparison of the value's internal state. As an example, for
* something like a date the comparison should be based on its internal "time" state based on the specific portion
* it is meant to represent (timestamp, date, time).
* Compare two instances of the class mapped by this type for persistence "equality",
* that is, equality of persistent state. For most types this could simply delegate to
* {@link java.util.Objects#equals(Object, Object) equals()}.
* <p>
* This should always equate to some form of comparison of the value's internal state.
* As an example, for Java's {@link java.util.Date} class, the comparison should be of
* its internal state, but based only on the specific part which is persistent (the
* timestamp, date, or time).
*
* @param x The first value
* @param y The second value
@ -151,12 +162,14 @@ public interface Type extends Serializable {
boolean isEqual(Object x, Object y) throws HibernateException;
/**
* Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
* state).
* Compare two instances of the class mapped by this type for persistence "equality",
* that is, equality of persistent state. For most types this could simply delegate to
* {@link #isEqual(Object, Object)}.
* <p/>
* This should always equate to some form of comparison of the value's internal state. As an example, for
* something like a date the comparison should be based on its internal "time" state based on the specific portion
* it is meant to represent (timestamp, date, time).
* This should always equate to some form of comparison of the value's internal state.
* As an example, for Java's {@link java.util.Date} class, the comparison should be of
* its internal state, but based only on the specific part which is persistent (the
* timestamp, date, or time).
*
* @param x The first value
* @param y The second value
@ -169,8 +182,8 @@ public interface Type extends Serializable {
boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) throws HibernateException;
/**
* Get a hash code, consistent with persistence "equality". Again for most types the normal usage is to
* delegate to the value's {@link Object#hashCode hashCode}.
* Get a hash code, consistent with persistence "equality". For most types this could
* simply delegate to the given value's {@link Object#hashCode() hashCode}.
*
* @param x The value for which to retrieve a hash code
* @return The hash code
@ -180,8 +193,8 @@ public interface Type extends Serializable {
int getHashCode(Object x) throws HibernateException;
/**
* Get a hash code, consistent with persistence "equality". Again for most types the normal usage is to
* delegate to the value's {@link Object#hashCode hashCode}.
* Get a hash code, consistent with persistence "equality". For most types this could
* simply delegate to {@link #getHashCode(Object)}.
*
* @param x The value for which to retrieve a hash code
* @param factory The session factory
@ -193,12 +206,14 @@ public interface Type extends Serializable {
int getHashCode(Object x, SessionFactoryImplementor factory) throws HibernateException;
/**
* Perform a {@link java.util.Comparator} style comparison between values
* Perform a {@link java.util.Comparator}-style comparison of the given values.
*
* @param x The first value
* @param y The second value
*
* @return The comparison result. See {@link java.util.Comparator#compare} for a discussion.
* @return The comparison result.
*
* @see java.util.Comparator#compare(Object, Object)
*/
int compare(Object x, Object y);
@ -231,10 +246,10 @@ public interface Type extends Serializable {
throws HibernateException;
/**
* Has the value been modified compared to the current database state? The difference between this
* and the {@link #isDirty} methods is that here we need to account for "partially" built values. This is really
* only an issue with association types. For most type implementations it is enough to simply delegate to
* {@link #isDirty} here/
* Has the value been modified compared to the current database state? The difference
* between this and the {@link #isDirty} methods is that here we need to account for
* "partially" built values. This is really only an issue with association types. For
* most type implementations it is enough to simply delegate to {@link #isDirty}.
*
* @param dbState the database state, in a "hydrated" form, with identifiers unresolved
* @param currentState the current state of the object
@ -253,9 +268,10 @@ public interface Type extends Serializable {
throws HibernateException;
/**
* Bind a value represented by an instance of the {@link #getReturnedClass() mapped class} to the JDBC prepared
* statement, ignoring some columns as dictated by the 'settable' parameter. Implementors should handle the
* possibility of null values. A multi-column type should bind parameters starting from {@code index}.
* Bind a value represented by an instance of the {@link #getReturnedClass() mapped class}
* to the given JDBC {@link PreparedStatement}, ignoring some columns as dictated by the
* {@code settable} parameter. Implementors should handle the possibility of null values.
* A multi-column type should bind parameters starting from {@code index}.
*
* @param st The JDBC prepared statement to which to bind
* @param value the object to write
@ -275,9 +291,10 @@ public interface Type extends Serializable {
throws HibernateException, SQLException;
/**
* Bind a value represented by an instance of the {@link #getReturnedClass() mapped class} to the JDBC prepared
* statement. Implementors should handle possibility of null values. A multi-column type should bind parameters
* starting from {@code index}.
* Bind a value represented by an instance of the {@link #getReturnedClass() mapped class}
* to the given JDBC {@link PreparedStatement}, ignoring some columns as dictated by the
* {@code settable} parameter. Implementors should handle the possibility of null values.
* A multi-column type should bind parameters starting from {@code index}.
*
* @param st The JDBC prepared statement to which to bind
* @param value the object to write
@ -291,7 +308,7 @@ public interface Type extends Serializable {
throws HibernateException, SQLException;
/**
* Generate a representation of the value for logging purposes.
* Generate a representation of the given value for logging purposes.
*
* @param value The value to be logged
* @param factory The session factory
@ -306,7 +323,7 @@ public interface Type extends Serializable {
/**
* Returns the abbreviated name of the type.
*
* @return String the Hibernate type name
* @return the Hibernate type name
*/
String getName();
@ -324,20 +341,31 @@ public interface Type extends Serializable {
throws HibernateException;
/**
* Are objects of this type mutable. (With respect to the referencing object ...
* entities and collections are considered immutable because they manage their
* own internal state.)
* Are objects of this type mutable with respect to the referencing object?
* Entities and collections are considered immutable because they manage their
* own internal state.
*
* @return boolean
*/
boolean isMutable();
/**
* Return a disassembled representation of the object. This is the value Hibernate will use in as cache key,
* so care should be taken to break values down to their simplest forms; for entities especially, this
* means breaking them down into their constituent parts.
*
* For two disassembled objects A and B, {@link Object#equals(Object)} must behave like {@link #isEqual(Object, Object)}.
* Return a disassembled representation of the object. This is the representation that
* is stored in the second-level cache.
* <p>
* A reference to an associated entity should be disassembled to its primary key value.
* <p>
* A high-quality implementation of this method should ensure that:
* <pre>
* {@code Objects.equals(disassemble(x,s), disassemble(y,s))} == isEqual(x,y,sf)
* </pre>
* and that:
* <pre>
* {@code Objects.equals(x, assemble(disassemble(x,s),s,o))}
* </pre>
* That is, the implementation must be consistent with
* {@link #isEqual(Object, Object, SessionFactoryImplementor)} and with
* {@link #assemble(Serializable, SharedSessionContractImplementor, Object)}.
*
* @param value the value to cache
* @param sessionFactory the session factory
@ -351,9 +379,10 @@ public interface Type extends Serializable {
}
/**
* Return a disassembled representation of the object. This is the value Hibernate will use in second level
* caching, so care should be taken to break values down to their simplest forms; for entities especially, this
* means breaking them down into their constituent parts.
* Return a disassembled representation of the object. This is the representation that
* is stored in the second-level cache.
* <p>
* A reference to an associated entity should be disassembled to its primary key value.
*
* @param value the value to cache
* @param session the originating session
@ -366,7 +395,8 @@ public interface Type extends Serializable {
Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException;
/**
* Reconstruct the object from its disassembled state. This method is the reciprocal of {@link #disassemble(Object, SharedSessionContractImplementor, Object)}
* Reconstruct the object from its disassembled state. This function is the inverse of
* {@link #disassemble(Object, SharedSessionContractImplementor, Object)}.
*
* @param cached the disassembled state from the cache
* @param session the originating session
@ -379,8 +409,8 @@ public interface Type extends Serializable {
Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException;
/**
* Called before assembling a query result set from the query cache, to allow batch fetching
* of entities missing from the second-level cache.
* Called before assembling a query result set from the query cache, to allow batch
* fetching of entities missing from the second-level cache.
*
* @param cached The key
* @param session The originating session
@ -438,8 +468,8 @@ public interface Type extends Serializable {
ForeignKeyDirection foreignKeyDirection) throws HibernateException;
/**
* Given an instance of the type, return an array of boolean, indicating
* which mapped columns would be null.
* Given an instance of the type, return an array of {@code boolean} values indicating which
* mapped columns would be null.
*
* @param value an instance of the type
* @param mapping The mapping abstraction

View File

@ -14,12 +14,13 @@ import org.hibernate.HibernateException;
import org.hibernate.internal.util.compare.ComparableComparator;
/**
* Abstract adapter for Java type descriptors.
* Abstract adapter for {@link JavaType Java type descriptors}.
*
* @apiNote This abstract descriptor implements {@link BasicJavaType}
* because we currently only categorize basic {@link JavaType}s, where
* "basic" is meant in the sense of the JPA specification, that is,
* {@link jakarta.persistence.metamodel.Type.PersistenceType#BASIC}.
*
* @apiNote This abstract descriptor implements BasicJavaType
* because we currently only categorize "basic" JavaTypes,
* as in the {@link jakarta.persistence.metamodel.Type.PersistenceType#BASIC}
* sense
*
* @author Steve Ebersole
*/

View File

@ -12,12 +12,14 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.descriptor.jdbc.JdbcTypeJavaClassMappings;
/**
* JavaType specialization for basic values
* Specializes {@link JavaType} for "basic" values, in the sense of
* {@link jakarta.persistence.metamodel.Type.PersistenceType#BASIC}.
*/
public interface BasicJavaType<T> extends JavaType<T> {
/**
* Obtain the "recommended" SQL type descriptor for this Java type. The recommended
* aspect comes from the JDBC spec (mostly).
* Obtain the "recommended" {@link JdbcType SQL type descriptor}
* for this Java type. Often, but not always, the source of this
* recommendation is the JDBC specification.
*
* @param indicators Contextual information
*
@ -25,13 +27,11 @@ public interface BasicJavaType<T> extends JavaType<T> {
*/
default JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
// match legacy behavior
final JdbcType descriptor = indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor(
JdbcTypeJavaClassMappings.INSTANCE.determineJdbcTypeCodeForJavaClass( getJavaTypeClass() )
);
if ( descriptor instanceof AdjustableJdbcType ) {
return ( (AdjustableJdbcType) descriptor ).resolveIndicatedType( indicators, this );
}
return descriptor;
int jdbcTypeCode = JdbcTypeJavaClassMappings.INSTANCE.determineJdbcTypeCodeForJavaClass( getJavaTypeClass() );
final JdbcType descriptor = indicators.getJdbcType( jdbcTypeCode );
return descriptor instanceof AdjustableJdbcType
? ((AdjustableJdbcType) descriptor).resolveIndicatedType( indicators, this )
: descriptor;
}
@Override

View File

@ -98,7 +98,8 @@ public class BlobJavaType extends AbstractClassJavaType<Blob> {
@Override
public Blob getReplacement(Blob original, Blob target, SharedSessionContractImplementor session) {
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy().mergeBlob( original, target, session );
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy()
.mergeBlob( original, target, session );
}
@Override

View File

@ -39,7 +39,7 @@ public class CalendarDateJavaType extends AbstractTemporalJavaType<Calendar> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.DATE );
return context.getJdbcType( Types.DATE );
}
@Override

View File

@ -48,7 +48,7 @@ public class CalendarJavaType extends AbstractTemporalJavaType<Calendar> impleme
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIMESTAMP );
return context.getJdbcType( Types.TIMESTAMP );
}
@Override

View File

@ -39,7 +39,7 @@ public class CalendarTimeJavaType extends AbstractTemporalJavaType<Calendar> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIME );
return context.getJdbcType( Types.TIME );
}
@Override

View File

@ -29,8 +29,8 @@ import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
/**
* Descriptor for {@link Clob} handling.
* <p/>
* Note, {@link Clob}s really are mutable (their internal state can in fact be mutated). We simply
* treat them as immutable because we cannot properly check them for changes nor deep copy them.
* Note, strictly-speaking a {@link Clob} object is actually mutable (its internal state can in fact be mutated).
* But we treat them as immutable because we simply have no way to dirty check nor deep copy them.
*
* @author Steve Ebersole
*/
@ -43,12 +43,9 @@ public class ClobJavaType extends AbstractClassJavaType<Clob> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
if ( indicators.isNationalized() ) {
final JdbcTypeRegistry stdRegistry = indicators.getTypeConfiguration().getJdbcTypeRegistry();
return stdRegistry.getDescriptor( Types.NCLOB );
}
return super.getRecommendedJdbcType( indicators );
return indicators.isNationalized()
? indicators.getJdbcType( Types.NCLOB )
: super.getRecommendedJdbcType( indicators );
}
@Override
@ -76,7 +73,8 @@ public class ClobJavaType extends AbstractClassJavaType<Clob> {
@Override
public Clob getReplacement(Clob original, Clob target, SharedSessionContractImplementor session) {
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy().mergeClob( original, target, session );
return session.getJdbcServices().getJdbcEnvironment().getDialect()
.getLobMergeStrategy().mergeClob( original, target, session );
}
@SuppressWarnings("unchecked")

View File

@ -57,7 +57,7 @@ public class DateJavaType extends AbstractTemporalJavaType<Date> implements Vers
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIMESTAMP );
return context.getJdbcType( Types.TIMESTAMP );
}
@Override

View File

@ -22,7 +22,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
* 28 decimal digits of precision. This quantity must be stored in
* the database as a single integer with units of nanoseconds, unless
* the ANSI SQL {@code interval} type is supported.
*
* <p>
* In practice, the 19 decimal digits of a SQL {@code bigint} are
* capable of representing six centuries in nanoseconds and are
* sufficient for many applications. However, by default, we map

View File

@ -17,7 +17,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
/**
* Describes a Java Enum type.
* Describes a Java {@code enum} type.
*
* @author Steve Ebersole
*/

View File

@ -31,7 +31,7 @@ public class FloatJavaType extends AbstractClassJavaType<Float> implements Primi
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.FLOAT );
return indicators.getJdbcType( SqlTypes.FLOAT );
}
@Override

View File

@ -45,7 +45,7 @@ public class InetAddressJavaType extends AbstractClassJavaType<InetAddress> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.INET );
return indicators.getJdbcType( SqlTypes.INET );
}
@SuppressWarnings("unchecked")

View File

@ -27,7 +27,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Java type descriptor for the LocalDateTime type.
* Java type descriptor for the Java {@link Instant} type.
*
* @author Steve Ebersole
*/
@ -67,7 +67,7 @@ public class InstantJavaType extends AbstractTemporalJavaType<Instant>
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( context.getPreferredSqlTypeCodeForInstant() );
return context.getJdbcType( context.getPreferredSqlTypeCodeForInstant() );
}
@Override

View File

@ -24,13 +24,48 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Descriptor for the Java side of a value mapping.
* Descriptor for the Java side of a value mapping. A {@code JavaType} is always
* coupled with a {@link JdbcType} to describe the typing aspects of an attribute
* mapping from Java to JDBC.
* <p>
* An instance of this interface represents a certain {@linkplain #getJavaType()
* Java class or interface} which may occur as the type of a persistent property
* or field of an entity class.
* <p>
* A {@code JavaType} decides how instances of the Java type are compared for
* {@linkplain #areEqual equality} and {@linkplain #getComparator order}, and
* it knows how to convert {@linkplain #unwrap to} and {@linkplain #wrap from}
* various different representations that might be requested by its partner
* {@link JdbcType}.
* <p>
* Every {@code JavaType} has a {@link MutabilityPlan} which defines how instances
* of the type are {@linkplain MutabilityPlan#deepCopy(Object) cloned}, and how
* they are {@linkplain MutabilityPlan#disassemble disassembled to} and
* {@linkplain MutabilityPlan#assemble assembled from} their representation in the
* {@linkplain org.hibernate.Cache second-level cache}.
* <p>
* Even though it's strictly only responsible for Java aspects of the mapping, a
* {@code JavaType} usually does come with a {@linkplain #getRecommendedJdbcType
* recommendation} for a friendly {@link JdbcType} it works particularly well
* with, along with a default {@linkplain #getDefaultSqlLength length},
* {@linkplain #getDefaultSqlPrecision precision}, and
* {@linkplain #getDefaultSqlScale scale} for mapped columns.
* <p>
* A Java type may be selected when mapping an entity attribute using the
* {@link org.hibernate.annotations.JavaType} annotation, though this is typically
* unnecessary.
* <p>
* Custom implementations should be registered with the
* {@link org.hibernate.type.descriptor.java.spi.JavaTypeRegistry} at startup.
* The built-in implementations are registered automatically.
*
* @see JdbcType
*
* @author Steve Ebersole
*/
public interface JavaType<T> extends Serializable {
/**
* Get the Java type (Type) described
* Get the Java type (a {@link Type} object) described by this {@code JavaType}.
*
* @see #getJavaTypeClass
*/
@ -40,7 +75,7 @@ public interface JavaType<T> extends Serializable {
}
/**
* Get the Java type (Class) described
* Get the Java type (the {@link Class} object) described by this {@code JavaType}.
*
* @see #getJavaType
*/
@ -50,23 +85,25 @@ public interface JavaType<T> extends Serializable {
/**
* Is the given value an instance of the described type?
*
* Generally this comes down to {@link #getJavaTypeClass() getJavaTypeClass().}{@link Class#isInstance isInstance()},
* though some descriptors (mainly the java.sql.Date, Time and Timestamp descriptors) might need different semantics
* <p>
* Usually just {@link #getJavaTypeClass() getJavaTypeClass().}{@link Class#isInstance isInstance(value)},
* but some descriptors need specialized semantics, for example, the descriptors for
* {@link JdbcDateJavaType java.sql.Date}, {@link JdbcTimeJavaType java.sql.Time}, and
* {@link JdbcTimestampJavaType java.sql.Timestamp}.
*/
default boolean isInstance(Object value) {
return getJavaTypeClass().isInstance( value );
}
/**
* Retrieve the mutability plan for this Java type.
* Retrieve the {@linkplain MutabilityPlan mutability plan} for this Java type.
*/
default MutabilityPlan<T> getMutabilityPlan() {
return ImmutableMutabilityPlan.instance();
}
default T getReplacement(T original, T target, SharedSessionContractImplementor session) {
if ( !getMutabilityPlan().isMutable() || ( target != null && areEqual( original, target ) ) ) {
if ( !getMutabilityPlan().isMutable() || target != null && areEqual( original, target ) ) {
return original;
}
else {
@ -84,8 +121,9 @@ public interface JavaType<T> extends Serializable {
}
/**
* Obtain the "recommended" SQL type descriptor for this Java type. The recommended
* aspect comes from the JDBC spec (mostly).
* Obtain the "recommended" {@link JdbcType SQL type descriptor}
* for this Java type. Often, but not always, the source of this
* recommendation is the JDBC specification.
*
* @param context Contextual information
*
@ -148,7 +186,7 @@ public interface JavaType<T> extends Serializable {
}
/**
* Extract a proper hash code for this value.
* Extract a proper hash code for the given value.
*
* @param value The value for which to extract a hash code.
*
@ -174,7 +212,7 @@ public interface JavaType<T> extends Serializable {
}
/**
* Extract a loggable representation of the value.
* Extract a loggable representation of the given value.
*
* @param value The value for which to extract a loggable representation.
*
@ -193,9 +231,9 @@ public interface JavaType<T> extends Serializable {
/**
* Unwrap an instance of our handled Java type into the requested type.
* <p/>
* As an example, if this is a {@code JavaType<Integer>} and we are asked to unwrap
* the {@code Integer value} as a {@code Long} we would return something like
* <code>Long.valueOf( value.longValue() )</code>.
* As an example, if this is a {@code JavaType<Integer>} and we are asked to
* unwrap the {@code Integer value} as a {@code Long}, we would return something
* like <code>Long.valueOf( value.longValue() )</code>.
* <p/>
* Intended use is during {@link java.sql.PreparedStatement} binding.
*
@ -222,8 +260,8 @@ public interface JavaType<T> extends Serializable {
<X> T wrap(X value, WrapperOptions options);
/**
* Returns whether this java type is wider than the given type
* i.e. if the given type can be widened to this java type.
* Determines if this Java type is wider than the given Java type,
* that is, if the given type can be safely widened to this type.
*/
default boolean isWider(JavaType<?> javaType) {
return false;
@ -252,8 +290,8 @@ public interface JavaType<T> extends Serializable {
}
/**
* Creates the {@link JavaType} for the given {@link ParameterizedType} based on this {@link JavaType} registered
* for the raw type.
* Creates the {@link JavaType} for the given {@link ParameterizedType}
* based on this {@link JavaType} registered for the raw type.
*
* @deprecated Use {@link #createJavaType(ParameterizedType, TypeConfiguration)} instead
*/
@ -263,8 +301,8 @@ public interface JavaType<T> extends Serializable {
}
/**
* Creates the {@link JavaType} for the given {@link ParameterizedType} based on this {@link JavaType} registered
* for the raw type.
* Creates the {@link JavaType} for the given {@link ParameterizedType}
* based on this {@link JavaType} registered for the raw type.
*
* @since 6.1
*/

View File

@ -207,7 +207,7 @@ public class JdbcDateJavaType extends AbstractTemporalJavaType<Date> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.DATE );
return context.getJdbcType( Types.DATE );
}
@Override

View File

@ -198,7 +198,7 @@ public class JdbcTimeJavaType extends AbstractTemporalJavaType<Date> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIME );
return context.getJdbcType( Types.TIME );
}
@Override

View File

@ -209,7 +209,7 @@ public class JdbcTimestampJavaType extends AbstractTemporalJavaType<Date> implem
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIMESTAMP );
return context.getJdbcType( Types.TIMESTAMP );
}
@Override

View File

@ -26,7 +26,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Java type descriptor for the LocalDateTime type.
* Java type descriptor for the {@link LocalDate} type.
*
* @author Steve Ebersole
*/
@ -47,7 +47,7 @@ public class LocalDateJavaType extends AbstractTemporalJavaType<LocalDate> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.DATE );
return context.getJdbcType( Types.DATE );
}
@Override

View File

@ -26,7 +26,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Java type descriptor for the LocalDateTime type.
* Java type descriptor for the {@link LocalDateTime} type.
*
* @author Steve Ebersole
*/
@ -48,7 +48,7 @@ public class LocalDateTimeJavaType extends AbstractTemporalJavaType<LocalDateTim
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIMESTAMP );
return context.getJdbcType( Types.TIMESTAMP );
}
@Override

View File

@ -29,7 +29,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Java type descriptor for the LocalDateTime type.
* Java type descriptor for the {@link LocalTime} type.
*
* @author Steve Ebersole
*/
@ -50,7 +50,7 @@ public class LocalTimeJavaType extends AbstractTemporalJavaType<LocalTime> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIME );
return context.getJdbcType( Types.TIME );
}
@Override

View File

@ -11,8 +11,13 @@ import java.io.Serializable;
import org.hibernate.SharedSessionContract;
/**
* Describes the mutability aspects of a Java type. The term mutability refers to the fact that generally speaking
* the aspects described by this contract are defined by whether the Java type's internal state is mutable or not.
* Describes the mutability aspects of a given Java type.
* <p>
* The term "mutability" refers to the fact that, generally speaking, the
* aspects described by this contract are determined by whether the Java
* type's internal state is mutable or immutable. For example, for an
* immutable Java class, {@link #deepCopy(Object)} may simply return its
* argument.
*
* @author Steve Ebersole
*/
@ -34,16 +39,22 @@ public interface MutabilityPlan<T> extends Serializable {
T deepCopy(T value);
/**
* Return a disassembled representation of the value. This is used to push values onto the
* second level cache. Compliment to {@link #assemble}
* Return a disassembled representation of the value.
*
* Called before storing a value in the second-level cache.
*
* Complementary to {@link #assemble}.
*
* @see #assemble
*/
Serializable disassemble(T value, SharedSessionContract session);
/**
* Assemble a previously {@linkplain #disassemble disassembled} value. This is used when pulling values from the
* second level cache. Compliment to {@link #disassemble}
* Assemble a previously {@linkplain #disassemble disassembled} value.
*
* Called after reading a value from the second level cache.
*
* Complementary to {@link #disassemble}.
*
* @see #disassemble
*/

View File

@ -29,7 +29,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Java type descriptor for the LocalDateTime type.
* Java type descriptor for the {@link OffsetTime} type.
*
* @author Steve Ebersole
*/
@ -50,7 +50,7 @@ public class OffsetTimeJavaType extends AbstractTemporalJavaType<OffsetTime> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.TIME );
return context.getJdbcType( Types.TIME );
}
@Override

View File

@ -66,7 +66,7 @@ public class SerializableJavaType<T extends Serializable> extends AbstractClassJ
final int typeCode = indicators.isLob()
? Types.BLOB
: Types.VARBINARY;
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( typeCode );
return indicators.getJdbcType( typeCode );
}
public String toString(T value) {

View File

@ -29,7 +29,7 @@ public class UUIDJavaType extends AbstractClassJavaType<UUID> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( context.getPreferredSqlTypeCodeForUuid() );
return context.getJdbcType( context.getPreferredSqlTypeCodeForUuid() );
}
public String toString(UUID value) {

View File

@ -29,7 +29,7 @@ public class UrlJavaType extends AbstractClassJavaType<URL> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.VARCHAR );
return context.getJdbcType( SqlTypes.VARCHAR );
}
public String toString(URL value) {

View File

@ -27,7 +27,7 @@ public class YearJavaType extends AbstractClassJavaType<Year> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.INTEGER );
return context.getJdbcType( Types.INTEGER );
}
@Override

View File

@ -14,7 +14,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* Describes the {@link ZoneId} Java type
* Describes the {@link ZoneId} Java type.
*/
public class ZoneIdJavaType extends AbstractClassJavaType<ZoneId> {
/**
@ -28,7 +28,7 @@ public class ZoneIdJavaType extends AbstractClassJavaType<ZoneId> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.VARCHAR );
return indicators.getJdbcType( Types.VARCHAR );
}
@Override

View File

@ -41,7 +41,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Descriptor for {@code Collection<T>} handling.
* Descriptor for handling persistent collections.
*
* @author Christian Beikov
*/
@ -67,10 +67,11 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
final int preferredSqlTypeCodeForArray = indicators.getPreferredSqlTypeCodeForArray();
// Always determine the recommended type to make sure this is a valid basic java type
// (even though we only use this inside the if block, we want it to throw here if something wrong)
final JdbcType recommendedComponentJdbcType = componentJavaType.getRecommendedJdbcType( indicators );
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
final JdbcType jdbcType = typeConfiguration.getJdbcTypeRegistry().getDescriptor( preferredSqlTypeCodeForArray );
final JdbcType jdbcType = indicators.getJdbcType( preferredSqlTypeCodeForArray );
if ( jdbcType instanceof ArrayJdbcType ) {
final TypeConfiguration typeConfiguration = indicators.getTypeConfiguration();
return ( (ArrayJdbcType) jdbcType ).resolveType(
typeConfiguration,
typeConfiguration.getServiceRegistry()
@ -80,7 +81,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
ColumnTypeInformation.EMPTY
);
}
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( preferredSqlTypeCodeForArray );
return jdbcType;
}
public CollectionSemantics<C, E> getSemantics() {
@ -94,7 +95,8 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
BasicType<E> elementType,
ColumnTypeInformation columnTypeInformation) {
final Class<?> elementJavaTypeClass = elementType.getJavaTypeDescriptor().getJavaTypeClass();
if ( elementType instanceof BasicPluralType<?, ?> || elementJavaTypeClass != null && elementJavaTypeClass.isArray() ) {
if ( elementType instanceof BasicPluralType<?, ?>
|| elementJavaTypeClass != null && elementJavaTypeClass.isArray() ) {
return null;
}
final BasicCollectionJavaType<C, E> collectionJavaType;
@ -229,8 +231,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
glue = ",";
}
sb.append( '}' );
final String result = sb.toString();
return result;
return sb.toString();
}
@Override
@ -238,7 +239,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
if ( charSequence == null ) {
return null;
}
java.util.ArrayList<String> lst = new java.util.ArrayList<>();
java.util.ArrayList<String> list = new java.util.ArrayList<>();
StringBuilder sb = null;
char lastChar = charSequence.charAt( charSequence.length() - 1 );
char firstChar = charSequence.charAt( 0 );
@ -251,7 +252,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
char c = charSequence.charAt( i );
if ( c == '"' ) {
if (inquote) {
lst.add( sb.toString() );
list.add( sb.toString() );
}
else {
sb = new StringBuilder();
@ -266,7 +267,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
else if ( c == ',' ) {
// treat no-value between commas to mean null
if ( sb == null ) {
lst.add( null );
list.add( null );
}
else {
sb = null;
@ -280,7 +281,7 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
&& charSequence.charAt( i + 1 ) == 'u'
&& charSequence.charAt( i + 2 ) == 'l'
&& charSequence.charAt( i + 3 ) == 'l') {
lst.add( null );
list.add( null );
i += 4;
continue;
}
@ -288,19 +289,20 @@ public class BasicCollectionJavaType<C extends Collection<E>, E> extends Abstrac
break;
}
throw new IllegalArgumentException( "Cannot parse given string into array of strings."
+ " Outside of quote, but neither whitespace, comma, array end, nor null found." );
+ " Outside of quote, but neither whitespace, comma, array end, nor null found." );
}
}
else if ( c == '\\' && i + 2 < len && (charSequence.charAt( i + 1 ) == '\\' || charSequence.charAt( i + 1 ) == '"')) {
else if ( c == '\\' && i + 2 < len && (charSequence.charAt( i + 1 ) == '\\'
|| charSequence.charAt( i + 1 ) == '"') ) {
c = charSequence.charAt( ++i );
}
// If there is ever a null-pointer here, the if-else logic before is incomplete
sb.append( c );
}
final C result = semantics.instantiateRaw( lst.size(), null );
for ( int i = 0; i < lst.size(); i ++ ) {
if ( lst.get( i ) != null ) {
result.add( componentJavaType.fromString( lst.get( i ) ) );
final C result = semantics.instantiateRaw( list.size(), null );
for ( int i = 0; i < list.size(); i ++ ) {
if ( list.get( i ) != null ) {
result.add( componentJavaType.fromString( list.get( i ) ) );
}
}
return result;

View File

@ -13,7 +13,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* EntityJavaType uses object identity for equals/hashCode as we ensure that internally.
* Uses object identity for {@code equals}/{@code hashCode} as we ensure that internally.
*
* @author Christian Beikov
*/

View File

@ -13,8 +13,8 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* AbstractBasicTypeDescriptor adapter for cases where we do not know a proper JavaType
* for a given Java type.
* {@link AbstractClassJavaType} for cases where we do not know a proper
* {@link org.hibernate.type.descriptor.java.JavaType} for a given Java type.
*
* @author Steve Ebersole
*/

View File

@ -16,13 +16,15 @@ import org.hibernate.type.descriptor.java.ArrayJavaType;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.MutabilityPlan;
import org.hibernate.type.descriptor.java.MutableMutabilityPlan;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.type.spi.TypeConfigurationAware;
import org.jboss.logging.Logger;
/**
* Basically a map from {@link Class} -> {@link JavaType}
* A registry mapping {@link Class Java classes} to implementations
* of the {@link JavaType} interface.
*
* @author Steve Ebersole
* @author Andrea Boriero

View File

@ -14,6 +14,8 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* Descriptor for {@link Map.Entry}.
*
* @author Steve Ebersole
*/
public class MapEntryJavaType extends AbstractClassJavaType<Map.Entry> {

View File

@ -15,8 +15,8 @@ import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
/**
* AbstractBasicTypeDescriptor adapter for cases where we do not know a proper JavaType
* for a given Java type.
* {@link AbstractJavaType} adapter for cases where we do not know a proper
* {@link org.hibernate.type.descriptor.java.JavaType} for a given Java type.
*/
public class UnknownBasicJavaType<T> extends AbstractJavaType<T> {
public UnknownBasicJavaType(Class<T> type) {

View File

@ -22,13 +22,24 @@ import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;
/**
* Descriptor for the SQL/JDBC side of a value mapping.
* Descriptor for the SQL/JDBC side of a value mapping. A {@code JdbcType} is
* always coupled with a {@link JavaType} to describe the typing aspects of an
* attribute mapping from Java to JDBC.
* <p>
* An instance of this type need not correspond directly to a SQL column type on
* a particular database. Rather, a {@code JdbcType} defines how values are read
* from and written to JDBC. Therefore, implementations of this interface map more
* directly to the JDBC type codes defined by {@link Types} and {@link SqlTypes}.
* <p>
* Every {@code JdbcType} has a {@link ValueBinder} and a {@link ValueExtractor}
* which, respectively, do the hard work of writing values to parameters of a
* JDBC {@link java.sql.PreparedStatement}, and reading values from the columns
* of a JDBC {@link java.sql.ResultSet}.
* <p>
* The {@linkplain #getJdbcTypeCode() JDBC type code} ultimately determines, in
* collaboration with the {@linkplain org.hibernate.dialect.Dialect SQL dialect},
* the SQL column type generated by Hibernate's schema export tool.
* <p>
* A JDBC type may be selected when mapping an entity attribute using the
* {@link org.hibernate.annotations.JdbcType} annotation, or, indirectly, using
* the {@link org.hibernate.annotations.JdbcTypeCode} annotation.

View File

@ -15,8 +15,8 @@ import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.spi.TypeConfiguration;
/**
* More-or-less a parameter-object intended for use in determining the SQL/JDBC type recommended
* by the JDBC spec (explicitly or implicitly) for a given Java type.
* A parameter object that helps in determine the {@link java.sql.Types SQL/JDBC type}
* recommended by the JDBC spec (explicitly or implicitly) for a given Java type.
*
* @see BasicJavaType#getRecommendedJdbcType
*
@ -30,7 +30,8 @@ public interface JdbcTypeIndicators {
/**
* Was nationalized character datatype requested for the given Java type?
*
* @return {@code true} if nationalized character datatype should be used; {@code false} otherwise.
* @return {@code true} if nationalized character datatype should be used;
* {@code false} otherwise.
*/
default boolean isNationalized() {
return false;
@ -39,7 +40,8 @@ public interface JdbcTypeIndicators {
/**
* Was LOB datatype requested for the given Java type?
*
* @return {@code true} if LOB datatype should be used; {@code false} otherwise.
* @return {@code true} if LOB datatype should be used;
* {@code false} otherwise.
*/
default boolean isLob() {
return false;
@ -64,56 +66,54 @@ public interface JdbcTypeIndicators {
/**
* When mapping a boolean type to the database what is the preferred SQL type code to use?
* <p/>
* Specifically names the key into the
* {@link JdbcTypeRegistry}.
* Returns a key into the {@link JdbcTypeRegistry}.
*/
default int getPreferredSqlTypeCodeForBoolean() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForBoolean();
return getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForBoolean();
}
/**
* When mapping a duration type to the database what is the preferred SQL type code to use?
* <p/>
* Specifically names the key into the
* {@link JdbcTypeRegistry}.
* Returns a key into the {@link JdbcTypeRegistry}.
*/
default int getPreferredSqlTypeCodeForDuration() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForDuration();
return getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForDuration();
}
/**
* When mapping an uuid type to the database what is the preferred SQL type code to use?
* <p/>
* Specifically names the key into the
* {@link JdbcTypeRegistry}.
* Returns a key into the {@link JdbcTypeRegistry}.
*/
default int getPreferredSqlTypeCodeForUuid() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForUuid();
return getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForUuid();
}
/**
* When mapping an instant type to the database what is the preferred SQL type code to use?
* <p/>
* Specifically names the key into the
* {@link JdbcTypeRegistry}.
* Returns a key into the {@link JdbcTypeRegistry}.
*/
default int getPreferredSqlTypeCodeForInstant() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForInstant();
return getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForInstant();
}
/**
* When mapping a basic array or collection type to the database what is the preferred SQL type code to use?
* <p/>
* Specifically names the key into the
* {@link JdbcTypeRegistry}.
* Returns a key into the {@link JdbcTypeRegistry}.
*
* @since 6.1
*/
default int getPreferredSqlTypeCodeForArray() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForArray();
return getCurrentBaseSqlTypeIndicators().getPreferredSqlTypeCodeForArray();
}
/**
* Useful for resolutions based on column length. E.g. choosing between a VARCHAR (String) and a CHAR(1) (Character/char)
* Useful for resolutions based on column length.
*
* E.g. for choosing between a {@code VARCHAR} ({@code String}) and {@code CHAR(1)} ({@code Character}/{@code char}).
*/
default long getColumnLength() {
return NO_COLUMN_LENGTH;
@ -127,18 +127,37 @@ public interface JdbcTypeIndicators {
}
/**
* Useful for resolutions based on column scale. E.g. choosing between a NUMERIC or INTERVAL
* Useful for resolutions based on column scale.
*
* E.g. for choosing between a {@code NUMERIC} and {@code INTERVAL SECOND}.
*/
default int getColumnScale() {
return NO_COLUMN_SCALE;
}
/**
* The default {@link TimeZoneStorageStrategy}.
*/
default TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators().getDefaultTimeZoneStorageStrategy();
return getCurrentBaseSqlTypeIndicators().getDefaultTimeZoneStorageStrategy();
}
/**
* Provides access to the TypeConfiguration for access to various type-system registries.
* The {@link JdbcType} registered under the given type code with the associated {@link JdbcTypeRegistry}.
*
* @param jdbcTypeCode a type code from {@link org.hibernate.type.SqlTypes}
* @return the {@link JdbcType} registered under that type code
*/
default JdbcType getJdbcType(int jdbcTypeCode) {
return getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode );
}
/**
* Provides access to the {@link TypeConfiguration} for access to various type system related registries.
*/
TypeConfiguration getTypeConfiguration();
private JdbcTypeIndicators getCurrentBaseSqlTypeIndicators() {
return getTypeConfiguration().getCurrentBaseSqlTypeIndicators();
}
}

View File

@ -24,6 +24,7 @@ import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.usertype.UserType;
/**
* Adaptor between {@link UserType} and {@link org.hibernate.type.descriptor.java.JavaType}.
*
* @author Steve Ebersole
*/
@ -81,7 +82,7 @@ public class UserTypeJavaTypeWrapper<J> implements BasicJavaType<J> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( userType.getSqlType() );
return context.getJdbcType( userType.getSqlType() );
}
@Override

View File

@ -33,8 +33,8 @@ import org.hibernate.type.spi.TypeConfiguration;
* <p>
* This interface:
* <ul>
* <li>abstracts user code away from changes to the interface
* {@link org.hibernate.type.Type},
* <li>abstracts user code away from changes to the internal interface
* {@link org.hibernate.type.Type},
* <li>simplifies the implementation of custom types, and
* <li>hides certain SPI interfaces from user code.
* </ul>
@ -61,9 +61,12 @@ import org.hibernate.type.spi.TypeConfiguration;
public interface UserType<J> {
/**
* Return the SQL type code for the column mapped by this type. The
* codes are generally defined on {@code org.hibernate.type.SqlTypes}, but could
* be database-specific codes
* The JDBC/SQL type code for the database column mapped by this
* custom type.
* <p>
* The type code is usually one of the standard type codes
* declared by {@link org.hibernate.type.SqlTypes}, but it could
* be a database-specific code.
*
* @see org.hibernate.type.SqlTypes
*/
@ -77,105 +80,171 @@ public interface UserType<J> {
Class<J> returnedClass();
/**
* Compare two instances of the class mapped by this type for persistence "equality".
* Equality of the persistent state.
* Compare two instances of the Java class mapped by this custom
* type for persistence "equality", that is, equality of their
* persistent state.
*/
boolean equals(J x, J y);
/**
* Get a hashcode for the instance, consistent with persistence "equality"
* Get a hash code for the given instance of the Java class mapped
* by this custom type, consistent with the definition of
* {@linkplain #equals(Object, Object) persistence "equality"} for
* this custom type.
*/
int hashCode(J x);
/**
* Retrieve an instance of the mapped class from a JDBC resultset. Implementors
* should handle possibility of null values.
* Read an instance of the Java class mapped by this custom type
* from the given JDBC {@link ResultSet}. Implementors must handle
* null column values.
*/
J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException;
J nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner)
throws SQLException;
/**
* Write an instance of the mapped class to a prepared statement. Implementors
* should handle possibility of null values. A multi-column type should be written
* to parameters starting from {@code index}.
* Write an instance of the Java class mapped by this custom type
* to the given JDBC {@link PreparedStatement}. Implementors must
* handle null values of the Java class. A multi-column type should
* be written to parameters starting from {@code index}.
*/
void nullSafeSet(PreparedStatement st, J value, int index, SharedSessionContractImplementor session) throws SQLException;
void nullSafeSet(PreparedStatement st, J value, int index, SharedSessionContractImplementor session)
throws SQLException;
/**
* Return a deep copy of the persistent state, stopping at entities and at
* collections. It is not necessary to copy immutable objects, or null
* values, in which case it is safe to simply return the argument.
* Return a clone of the given instance of the Java class mapped
* by this custom type.
* <ul>
* <li>It's not necessary to clone immutable objects. If the Java
* class mapped by this custom type is an immutable class,
* this method may safely just return its argument.
* <li>For mutable objects, it's necessary to deep copy persistent
* state, stopping at associations to other entities, and at
* persistent collections.
* <li>If the argument is a reference to an entity, just return
* the argument.
* <li>Finally, if the argument is null, just return null.
* </ul>
*
* @param value the object to be cloned, which may be null
* @return Object a copy
* @return a clone
*/
J deepCopy(J value);
/**
* Are objects of this type mutable?
* Are instances of the Java class mapped by this custom type
* mutable or immutable?
*
* @return boolean
* @return {@code true} if instances are mutable
*/
boolean isMutable();
/**
* Transform the object into its cacheable representation. At the very least this
* method should perform a deep copy if the type is mutable. That may not be enough
* for some implementations, however; for example, associations must be cached as
* identifier values. (optional operation)
* Transform the given value into a destructured representation,
* suitable for storage in the {@linkplain org.hibernate.Cache
* second-level cache}. This method is called only during the
* process of writing the properties of an entity to the
* second-level cache.
* <p>
* If the value is mutable then, at the very least, this method
* should perform a deep copy. That may not be enough for some
* types, however. For example, associations must be cached as
* identifier values.
* <p>
* This is an optional operation, but, if left unimplemented,
* this type will not be cacheable in the second-level cache.
*
* @param value the object to be cached
* @return a cacheable representation of the object
*
* @see org.hibernate.Cache
*/
Serializable disassemble(J value);
/**
* Reconstruct an object from the cacheable representation. At the very least this
* method should perform a deep copy if the type is mutable. (optional operation)
* Reconstruct a value from its destructured representation,
* during the process of reading the properties of an entity
* from the {@linkplain org.hibernate.Cache second-level cache}.
* <p>
* If the value is mutable then, at the very least, this method
* should perform a deep copy. That may not be enough for some
* types, however. For example, associations must be cached as
* identifier values.
* <p>
* This is an optional operation, but, if left unimplemented,
* this type will not be cacheable in the second-level cache.
*
* @param cached the object to be cached
* @param owner the owner of the cached object
* @return a reconstructed object from the cacheable representation
*
* @see org.hibernate.Cache
*/
J assemble(Serializable cached, Object owner);
/**
* During merge, replace the existing (target) value in the entity we are merging to
* with a new (original) value from the detached entity we are merging. For immutable
* objects, or null values, it is safe to simply return the first parameter. For
* mutable objects, it is safe to return a copy of the first parameter. For objects
* with component values, it might make sense to recursively replace component values.
* During merge, replace the existing (target) value in the
* managed entity we are merging to with a new (original) value
* from the detached entity we are merging.
* <ul>
* <li>For immutable objects, or null values, it's safe to simply
* return the first argument.
* <li>For mutable objects, it's enough to return a copy of the
* first argument.
* <li>For objects with component values, it might make sense to
* recursively replace component values.
* </ul>
*
* @param detached the value from the detached entity being merged
* @param managed the value in the managed entity
*
* @return the value to be merged
*
* @see org.hibernate.Session#merge(Object)
*/
J replace(J detached, J managed, Object owner);
/**
* The default column length, for use in DDL generation.
*/
default long getDefaultSqlLength(Dialect dialect, JdbcType jdbcType) {
return Size.DEFAULT_LENGTH;
}
/**
* The default column precision, for use in DDL generation.
*/
default int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType) {
return Size.DEFAULT_PRECISION;
}
/**
* The default column scale, for use in DDL generation.
*/
default int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType) {
return Size.DEFAULT_SCALE;
}
/**
* A mapped {@link JdbcType}. By default, the {@code JdbcType}
* registered under our {@link #getSqlType() type code}.
*/
@Incubating
default JdbcType getJdbcType(TypeConfiguration typeConfiguration) {
return typeConfiguration.getJdbcTypeRegistry().getDescriptor( getSqlType() );
}
/**
* Returns the converter that this user type uses for transforming from the domain type, to the relational type,
* or <code>null</code> if there is no conversion.
*
* Note that it is vital to provide a converter if a column should be mapped to multiple domain types,
* as Hibernate will only select a column once and materialize values as {@link JdbcMapping#getJdbcJavaType()}.
* Support for multiple domain type representations works by converting objects of that type to the domain type.
* Returns the converter that this custom type uses for transforming
* from the domain type to the relational type, or <code>null</code>
* if there is no conversion.
* <p>
* Note that it is vital to provide a converter if a column should
* be mapped to multiple domain types, as Hibernate will only select
* a column once and materialize values as instances of the Java type
* given by {@link JdbcMapping#getJdbcJavaType()}. Support for multiple
* domain type representations works by converting objects of that type
* to the domain type.
*/
@Incubating
default BasicValueConverter<J, Object> getValueConverter() {

View File

@ -33,7 +33,7 @@ public class InetJavaType extends AbstractClassJavaType<Inet> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.INET );
return indicators.getJdbcType( SqlTypes.INET );
}
@Override

View File

@ -325,7 +325,7 @@ public class ExplicitJavaTypeDescriptorTest extends BaseNonConfigCoreFunctionalT
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.VARCHAR );
return context.getJdbcType( Types.VARCHAR );
}
@Override

View File

@ -33,7 +33,7 @@ public class StringArrayJavaType implements BasicJavaType<String[]> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.ARRAY );
return context.getJdbcType( Types.ARRAY );
}
@Override

View File

@ -23,7 +23,7 @@ public class ArrayJavaType extends AbstractClassJavaType<Array> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( Types.VARCHAR );
return indicators.getJdbcType( Types.VARCHAR );
}
@Override

View File

@ -79,7 +79,7 @@ public class GeolatteGeometryJavaType extends AbstractJavaType<Geometry> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.GEOMETRY );
return indicators.getJdbcType( SqlTypes.GEOMETRY );
}
@Override

View File

@ -81,7 +81,7 @@ public class JTSGeometryJavaType extends AbstractJavaType<Geometry> {
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return indicators.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( SqlTypes.GEOMETRY );
return indicators.getJdbcType( SqlTypes.GEOMETRY );
}
@Override