Class ConvertedBasicTypeImpl<J>
- All Implemented Interfaces:
BasicType<J>,Type<J>,Serializable,BasicValuedMapping,Bindable,JdbcMapping,JdbcMappingContainer,MappingModelExpressible,MappingType,SqlExpressible,ValueMapping,BasicDomainType<J>,DomainType<J>,SimpleDomainType<J>,BindableType<J>,OutputableType<J>,ReturnableType<J>,SqmExpressible<J>,AdjustableBasicType<J>,BasicType<J>,ConvertedBasicType<J>,JavaTypedExpressible,ProcedureParameterExtractionAware<J>,ProcedureParameterNamedBinder<J>,Type
- Direct Known Subclasses:
CustomMutabilityConvertedBasicTypeImpl,DiscriminatorTypeImpl
- Author:
- Christian Beikov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.metamodel.mapping.Bindable
Bindable.JdbcValuesBiConsumer<X,Y>, Bindable.JdbcValuesConsumer Nested classes/interfaces inherited from interface jakarta.persistence.metamodel.Type
Type.PersistenceType -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConvertedBasicTypeImpl(String name, String description, JdbcType jdbcType, BasicValueConverter<J, ?> converter) ConvertedBasicTypeImpl(String name, JdbcType jdbcType, BasicValueConverter<J, ?> converter) -
Method Summary
Modifier and TypeMethodDescriptionfinal Objectassemble(Serializable cached, SharedSessionContractImplementor session, Object owner) Reconstruct the object from its disassembled state.final voidbeforeAssemble(Serializable cached, SharedSessionContractImplementor session) Called before assembling a query result set from the query cache, to allow batch fetching of entities missing from the second-level cache.booleanCan the given instance of this type actually perform the parameter value extractions?booleanCan the given instance of this type actually set the parameter value by namefinal intPerform aComparator-style comparison of the given values.final ObjectdeepCopy(Object value, SessionFactoryImplementor factory) Return a deep copy of the persistent state, stopping at entities and at collections.disassemble(Object value, SharedSessionContractImplementor session) Breaks down a value ofJinto its simple pieces.final Serializabledisassemble(Object value, SharedSessionContractImplementor session, Object owner) Return a disassembled representation of the object.extract(CallableStatement statement, int startIndex, SharedSessionContractImplementor session) Perform the extractionextract(CallableStatement statement, String paramName, SharedSessionContractImplementor session) Perform the extractionfinal intgetColumnSpan(Mapping mapping) How many columns are used to persist this type?intGet a hash code, consistent with persistence "equality".final intgetHashCode(Object x, SessionFactoryImplementor factory) Get a hash code, consistent with persistence "equality".Return the represented Java type.The descriptor for the Java type represented by this expressible typeJavaType<?>The strategy for formatting values of this expressible type to a SQL literal.final JdbcTypeDescriptor for the SQL type mapped by this type.The strategy for binding values of this expressible type to JDBCPreparedStatements andCallableStatements.The strategy for extracting values of this expressible type from JDBC ResultSets, CallableStatements, etcprotected MutabilityPlan<J>getName()Returns the abbreviated name of the type.String[]Get the names under which this type should be registered in the type registry.final ClassThe class handled by this type.final int[]getSqlTypeCodes(Mapping mapping) Returns the converter that this basic type uses for transforming from the domain type, to the relational type, ornullif there is no conversion.final booleanReturn true if the implementation is castable toAnyType.final booleanReturn true if the implementation is castable toAssociationType.final booleanReturn true if the implementation is castable toCollectionType.final booleanReturn true if the implementation is castable toCompositeType.protected final booleanfinal booleanisDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) Should the parent be considered dirty, given both the old and current value?final booleanisDirty(Object old, Object current, SharedSessionContractImplementor session) Should the parent be considered dirty, given both the old and current value?final booleanReturn true if the implementation is castable toEntityType.booleanCompare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state.final booleanisEqual(Object x, Object y, SessionFactoryImplementor factory) Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state.final booleanisModified(Object oldHydratedState, Object currentState, boolean[] checkable, SharedSessionContractImplementor session) Has the value been modified compared to the current database state?final booleanAre objects of this type mutable with respect to the referencing object?final booleanCompare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state, taking a shortcut for entity references.voidnullSafeSet(CallableStatement st, J value, String name, SharedSessionContractImplementor session) Bind a value to the JDBC prepared statement, ignoring some columns as dictated by the 'settable' parameter.final voidnullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SharedSessionContractImplementor session) Bind a value represented by an instance of themapped classto the given JDBCPreparedStatement, ignoring some columns as dictated by thesettableparameter.final voidnullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) Bind a value represented by an instance of themapped classto the given JDBCPreparedStatement, ignoring some columns as dictated by thesettableparameter.final Objectreplace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache) 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.replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object, Object> copyCache, ForeignKeyDirection foreignKeyDirection) 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.boolean[]toColumnNullness(Object value, Mapping mapping) Given an instance of the type, return an array ofbooleanvalues indicating which mapped columns would be null.final StringtoLoggableString(Object value, SessionFactoryImplementor factory) Generate a representation of the given value for logging purposes.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hibernate.type.AdjustableBasicType
resolveIndicatedTypeMethods inherited from interface org.hibernate.metamodel.model.domain.BasicDomainType
areEqual, getPersistenceTypeMethods inherited from interface org.hibernate.type.BasicType
compare, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcType, getCheckCondition, getExpressibleJavaType, getJdbcMapping, getJdbcMapping, getJdbcTypeCount, getMappedJavaType, getMappedType, getSingleJdbcMappingMethods inherited from interface org.hibernate.metamodel.mapping.BasicValuedMapping
addToCacheKeyMethods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValueMethods inherited from interface org.hibernate.metamodel.model.domain.DomainType
getSqmType, getTupleLengthMethods inherited from interface org.hibernate.metamodel.mapping.JdbcMapping
convertToDomainValue, convertToRelationalValueMethods inherited from interface org.hibernate.metamodel.model.domain.SimpleDomainType
getBindableJavaTypeMethods inherited from interface org.hibernate.query.sqm.SqmExpressible
getRelationalJavaType, getTypeName, isInstance, resolveExpressibleMethods inherited from interface org.hibernate.type.Type
disassemble, getReturnedClassName, getTypeForEqualsHashCodeMethods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
treatAs
-
Field Details
-
EXTERNALIZED_PREFIX
- See Also:
-
NO_REG_KEYS
-
-
Constructor Details
-
ConvertedBasicTypeImpl
-
ConvertedBasicTypeImpl
public ConvertedBasicTypeImpl(String name, String description, JdbcType jdbcType, BasicValueConverter<J, ?> converter)
-
-
Method Details
-
getName
Description copied from interface:TypeReturns the abbreviated name of the type. -
getRegistrationKeys
Description copied from interface:BasicTypeGet the names under which this type should be registered in the type registry.- Specified by:
getRegistrationKeysin interfaceBasicType<J>- Returns:
- The keys under which to register this type.
-
getValueConverter
Description copied from interface:JdbcMappingReturns the converter that this basic type uses for transforming from the domain type, to the relational type, ornullif there is no conversion.- Specified by:
getValueConverterin interfaceBasicType<J>- Specified by:
getValueConverterin interfaceConvertedBasicType<J>- Specified by:
getValueConverterin interfaceJdbcMapping
-
getJdbcValueExtractor
Description copied from interface:JdbcMappingThe strategy for extracting values of this expressible type from JDBC ResultSets, CallableStatements, etc- Specified by:
getJdbcValueExtractorin interfaceBasicType<J>- Specified by:
getJdbcValueExtractorin interfaceJdbcMapping
-
getJdbcValueBinder
Description copied from interface:JdbcMappingThe strategy for binding values of this expressible type to JDBCPreparedStatements andCallableStatements.- Specified by:
getJdbcValueBinderin interfaceBasicType<J>- Specified by:
getJdbcValueBinderin interfaceJdbcMapping
-
getJdbcLiteralFormatter
Description copied from interface:JdbcMappingThe strategy for formatting values of this expressible type to a SQL literal.- Specified by:
getJdbcLiteralFormatterin interfaceBasicType<J>- Specified by:
getJdbcLiteralFormatterin interfaceJdbcMapping
-
getJavaType
Description copied from interface:TypeReturn the represented Java type.- Specified by:
getJavaTypein interfaceType<J>- Returns:
- Java type
-
getJdbcJavaType
- Specified by:
getJdbcJavaTypein interfaceJdbcMapping
-
toColumnNullness
Description copied from interface:TypeGiven an instance of the type, return an array ofbooleanvalues indicating which mapped columns would be null.- Specified by:
toColumnNullnessin interfaceType- Parameters:
value- an instance of the typemapping- The mapping abstraction- Returns:
- array indicating column nullness for a value instance
-
getJavaTypeDescriptor
Description copied from interface:JdbcMappingThe descriptor for the Java type represented by this expressible type- Specified by:
getJavaTypeDescriptorin interfaceBasicType<J>- Specified by:
getJavaTypeDescriptorin interfaceJdbcMapping
-
getJdbcType
Description copied from interface:OutputableTypeDescriptor for the SQL type mapped by this type.- Specified by:
getJdbcTypein interfaceJdbcMapping- Specified by:
getJdbcTypein interfaceOutputableType<J>
-
getReturnedClass
Description copied from interface:TypeThe class handled by this type.- Specified by:
getReturnedClassin interfaceType- Returns:
- The Java class handled by this type.
-
getColumnSpan
Description copied from interface:TypeHow many columns are used to persist this type?Always the same as
getSqlTypCodes(mapping).length.- Specified by:
getColumnSpanin interfaceType- Parameters:
mapping- The mapping object :/- Returns:
- The number of columns
- Throws:
MappingException- Generally indicates an issue accessing the passed mapping object.
-
getSqlTypeCodes
Description copied from interface:TypeReturn the JDBC types codes as defined byTypesorSqlTypesfor the columns mapped by this type.The number of elements in this array must match the return from
Type.getColumnSpan(org.hibernate.engine.spi.Mapping).- Specified by:
getSqlTypeCodesin interfaceType- Parameters:
mapping- The mapping object :/- Returns:
- The JDBC type codes.
- Throws:
MappingException- Generally indicates an issue accessing the passed mapping object.
-
isAssociationType
public final boolean isAssociationType()Description copied from interface:TypeReturn true if the implementation is castable toAssociationType. This does not necessarily imply that the type actually represents an association. Shortcut fortype instanceof AssociationType.- Specified by:
isAssociationTypein interfaceType- Returns:
- True if this type is also an
AssociationTypeimplementor; false otherwise.
-
isCollectionType
public final boolean isCollectionType()Description copied from interface:TypeReturn true if the implementation is castable toCollectionType. Shortcut fortype instanceof CollectionTypeA
CollectionTypeis additionally anAssociationType; so if this method returns true,Type.isAssociationType()should also return true.- Specified by:
isCollectionTypein interfaceType- Returns:
- True if this type is also a
CollectionTypeimplementor; false otherwise.
-
isComponentType
public final boolean isComponentType()Description copied from interface:TypeReturn true if the implementation is castable toCompositeType. Shortcut fortype instanceof CompositeType.A component type may own collections or associations and hence must provide certain extra functionality.
- Specified by:
isComponentTypein interfaceType- Returns:
- True if this type is also a
CompositeTypeimplementor; false otherwise.
-
isEntityType
public final boolean isEntityType()Description copied from interface:TypeReturn true if the implementation is castable toEntityType. Shortcut fortype instanceof EntityType.An
EntityTypeis additionally anAssociationType; so if this method returns true,Type.isAssociationType()should also return true.- Specified by:
isEntityTypein interfaceType- Returns:
- True if this type is also an
EntityTypeimplementor; false otherwise.
-
isAnyType
public final boolean isAnyType()Description copied from interface:TypeReturn true if the implementation is castable toAnyType. Shortcut fortype instanceof AnyType.An
AnyTypeis additionally anAssociationType; so if this method returns true, thenType.isAssociationType()should also return true. -
isSame
Description copied from interface:TypeCompare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state, taking a shortcut for entity references.For most types this should boil down to an equality comparison of the given values, and it's reasonable to simply delegate to
Type.isEqual(Object, Object). But for associations the semantics are a bit different. -
isEqual
Description copied from interface:TypeCompare 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 toType.isEqual(Object, Object).This should always equate to some form of comparison of the value's internal state. As an example, for Java's
Dateclass, the comparison should be of its internal state, but based only on the specific part which is persistent (the timestamp, date, or time). -
isEqual
Description copied from interface:TypeCompare 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 toequals().This should always equate to some form of comparison of the value's internal state. As an example, for Java's
Dateclass, the comparison should be of its internal state, but based only on the specific part which is persistent (the timestamp, date, or time). -
getHashCode
Description copied from interface:TypeGet a hash code, consistent with persistence "equality". For most types this could simply delegate to the given value'shashCode.- Specified by:
getHashCodein interfaceType- Parameters:
x- The value for which to retrieve a hash code- Returns:
- The hash code
-
getHashCode
Description copied from interface:TypeGet a hash code, consistent with persistence "equality". For most types this could simply delegate toType.getHashCode(Object).- Specified by:
getHashCodein interfaceType- Parameters:
x- The value for which to retrieve a hash codefactory- The session factory- Returns:
- The hash code
-
compare
Description copied from interface:TypePerform aComparator-style comparison of the given values. -
isDirty
-
toLoggableString
Description copied from interface:TypeGenerate a representation of the given value for logging purposes.- Specified by:
toLoggableStringin interfaceType- Parameters:
value- The value to be loggedfactory- The session factory- Returns:
- The loggable representation
-
getMutabilityPlan
-
isMutable
public final boolean isMutable()Description copied from interface:TypeAre objects of this type mutable with respect to the referencing object? Entities and collections are considered immutable because they manage their own internal state. -
deepCopy
Description copied from interface:TypeReturn a deep copy of the persistent state, stopping at entities and at collections. -
canDoExtraction
public boolean canDoExtraction()Description copied from interface:OutputableTypeCan the given instance of this type actually perform the parameter value extractions?- Specified by:
canDoExtractionin interfaceOutputableType<J>- Returns:
trueindicates thatOutputableType.extract(java.sql.CallableStatement, int, org.hibernate.engine.spi.SharedSessionContractImplementor)calls will not fail due toIllegalStateException.
-
canDoSetting
public boolean canDoSetting()Description copied from interface:ProcedureParameterNamedBinderCan the given instance of this type actually set the parameter value by name- Specified by:
canDoSettingin interfaceProcedureParameterNamedBinder<J>- Returns:
trueindicates that @{link #nullSafeSet} calls will not fail
-
getCastType
- Specified by:
getCastTypein interfaceJdbcMapping
-
toString
-