Class CustomType<J>
- All Implemented Interfaces:
BasicType<J>,Type<J>,Serializable,BasicValuedMapping,Bindable,JdbcMapping,JdbcMappingContainer,MappingModelExpressible,MappingType,SqlExpressible,ValueMapping,BasicDomainType<J>,DomainType<J>,ReturnableType<J>,SimpleDomainType<J>,SqmBindableType<J>,SqmExpressible<J>,SqmDomainType<J>,BasicType<J>,BindableType<J>,ConvertedBasicType<J>,JavaTypedExpressible,OutputableType<J>,ProcedureParameterExtractionAware<J>,ProcedureParameterNamedBinder<J>,Type
UserType to the generic Type interface, in order
to isolate user code from changes in the internal Type contracts.- See Also:
- API Note:
- Many of the interfaces implemented here are implemented just to handle the case of the wrapped type implementing them so we can pass them along.
-
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 -
Constructor Summary
ConstructorsConstructorDescriptionCustomType(UserType<J> userType, String[] registrationKeys, TypeConfiguration typeConfiguration) CustomType(UserType<J> userType, TypeConfiguration typeConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToCacheKey(MutableCacheKeyBuilder cacheKey, Object value, SharedSessionContractImplementor session) Add to the MutableCacheKey the values obtained disassembling the value and the hasCode generated from the disassembled value.assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) Reconstruct the object from its disassembled state.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 namedeepCopy(Object value, SessionFactoryImplementor factory) Return a deep copy of the persistent state, stopping at entities and at collections.disassemble(Object value, SessionFactoryImplementor sessionFactory) Return a disassembled representation of the object.disassemble(Object value, SharedSessionContractImplementor session) Breaks down a value ofJinto its simple pieces.disassemble(Object value, SharedSessionContractImplementor session, Object owner) Return a disassembled representation of the object.booleanextract(CallableStatement statement, int startIndex, SharedSessionContractImplementor session) Perform the extractionextract(CallableStatement statement, String paramName, SharedSessionContractImplementor session) Perform the extractionintgetColumnSpan(MappingContext session) How many columns are used to persist this type?TheJavaTyperepresenting this domain type.intGet a hash code, consistent with persistence "equality".The Java class which represents by this domain 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.Descriptor 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, etcThe descriptor descriptor for the mapped Java typegetName()Returns the abbreviated name of the type.String[]Get the names under which this type should be registered in the type registry.The class handled by this type.int[]getSqlTypeCodes(MappingContext mappingContext) Returns the converter that this basic type uses for transforming from the domain type, to the relational type, ornullif there is no conversion.inthashCode()booleanisDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) Should the parent be considered dirty, given both the old and current value?booleanCompare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state.booleanAre objects of this type mutable with respect to the referencing object? Entities and collections are considered immutable because they manage their own internal state.voidnullSafeSet(CallableStatement statement, J value, String name, SharedSessionContractImplementor session) Bind a value to the JDBC prepared statement, ignoring some columns as dictated by the 'settable' parameter.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.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.replace(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.boolean[]toColumnNullness(Object value, MappingContext mapping) Given an instance of the type, return an array ofbooleanvalues indicating which mapped columns would be null.toLoggableString(Object value, SessionFactoryImplementor factory) Generate a representation of the given value for logging purposes.Methods inherited from class org.hibernate.type.AbstractType
beforeAssemble, compare, getHashCode, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isEntityType, isEqual, isModified, isSame, replaceMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.metamodel.model.domain.BasicDomainType
getPersistenceTypeMethods inherited from interface org.hibernate.type.BasicType
compare, forEachDisassembledJdbcValue, forEachJdbcType, forEachJdbcType, getCheckCondition, getJdbcMapping, getJdbcMapping, getJdbcTypeCount, getMappedType, getSingleJdbcMapping, getSqmTypeMethods inherited from interface org.hibernate.metamodel.mapping.Bindable
forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachDisassembledJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValue, forEachJdbcValueMethods inherited from interface org.hibernate.metamodel.mapping.JdbcMapping
convertToDomainValue, convertToRelationalValue, getCastTypeMethods inherited from interface org.hibernate.query.sqm.SqmBindableType
resolveExpressibleMethods inherited from interface org.hibernate.query.sqm.tree.domain.SqmDomainType
getTupleLength, getTypeNameMethods inherited from interface org.hibernate.query.sqm.SqmExpressible
getRelationalJavaTypeMethods inherited from interface org.hibernate.type.Type
beforeAssemble, compare, getHashCode, getReturnedClassName, getTypeForEqualsHashCode, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isEntityType, isEqual, isModified, isSame, replaceMethods inherited from interface org.hibernate.metamodel.mapping.ValueMapping
treatAs
-
Constructor Details
-
CustomType
public CustomType(UserType<J> userType, TypeConfiguration typeConfiguration) throws MappingException - Throws:
MappingException
-
CustomType
public CustomType(UserType<J> userType, String[] registrationKeys, TypeConfiguration typeConfiguration)
-
-
Method Details
-
getUserType
-
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
-
getJdbcType
Description copied from interface:OutputableTypeDescriptor for the SQL type mapped by this type.- Specified by:
getJdbcTypein interfaceJdbcMapping- Specified by:
getJdbcTypein interfaceOutputableType<J>
-
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.type.MappingContext).- Specified by:
getSqlTypeCodesin interfaceType- Parameters:
mappingContext- The mapping contextMappingContext:/- Returns:
- The JDBC type codes.
-
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.
-
getColumnSpan
Description copied from interface:TypeHow many columns are used to persist this type?Always the same as
getSqlTypCodes(mappingContext).length.- Specified by:
getColumnSpanin interfaceType- Parameters:
session- The mapping Context objectMappingContext- Returns:
- The number of columns
-
getReturnedClass
Description copied from interface:TypeThe class handled by this type.- Specified by:
getReturnedClassin interfaceType- Returns:
- The Java class handled by this type.
-
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).- Specified by:
isEqualin interfaceType- Overrides:
isEqualin classAbstractType- Parameters:
x- The first valuey- The second value- Returns:
- True if there are considered equal (see discussion above).
- Throws:
HibernateException- A problem occurred performing the comparison
-
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- Overrides:
getHashCodein classAbstractType- Parameters:
x- The value for which to retrieve a hash code- Returns:
- The hash code
-
disassemble
Description copied from interface:TypeReturn a disassembled representation of the object. This is the representation that is stored in the second-level cache.A reference to an associated entity should be disassembled to its primary key value.
A high-quality implementation of this method should ensure that:
Objects.equals(disassemble(x,s), disassemble(y,s))== isEqual(x,y,sf)and that:
Objects.equals(x, assemble(disassemble(x,s),s,o))That is, the implementation must be consistent with
Type.isEqual(Object, Object, SessionFactoryImplementor)and withType.assemble(Serializable, SharedSessionContractImplementor, Object).- Specified by:
disassemblein interfaceType- Overrides:
disassemblein classAbstractType- Parameters:
value- the value to cachesessionFactory- the session factory- Returns:
- the disassembled, deep cloned state
-
getName
Description copied from interface:TypeReturns the abbreviated name of the type. -
deepCopy
Description copied from interface:TypeReturn a deep copy of the persistent state, stopping at entities and at collections.- Specified by:
deepCopyin interfaceType- Parameters:
value- The value to be copiedfactory- The session factory- Returns:
- The deep copy
- Throws:
HibernateException- An error from Hibernate
-
isMutable
public 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. -
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
-
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 contextMappingContext- Returns:
- array indicating column nullness for a value instance
-
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
-
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.
-
hashCode
public int hashCode() -
equals
-
getJavaType
Description copied from interface:DomainTypeThe Java class which represents by this domain type.- Specified by:
getJavaTypein interfaceBasicDomainType<J>- Specified by:
getJavaTypein interfaceBasicType<J>- Specified by:
getJavaTypein interfaceDomainType<J>- Specified by:
getJavaTypein interfaceSimpleDomainType<J>- Specified by:
getJavaTypein interfaceType<J>- See Also:
-
getMappedJavaType
Description copied from interface:MappingTypeThe descriptor descriptor for the mapped Java type- Specified by:
getMappedJavaTypein interfaceBasicType<J>- Specified by:
getMappedJavaTypein interfaceJdbcMapping- Specified by:
getMappedJavaTypein interfaceMappingType
-
getExpressibleJavaType
Description copied from interface:DomainTypeTheJavaTyperepresenting this domain type.- Specified by:
getExpressibleJavaTypein interfaceBasicType<J>- Specified by:
getExpressibleJavaTypein interfaceDomainType<J>- Specified by:
getExpressibleJavaTypein interfaceJavaTypedExpressible<J>- Specified by:
getExpressibleJavaTypein interfaceSqmExpressible<J>- Specified by:
getExpressibleJavaTypein interfaceValueMapping
-
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
-
getJdbcJavaType
- Specified by:
getJdbcJavaTypein interfaceJdbcMapping
-
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
-