Class UserComponentType<T>
- java.lang.Object
-
- org.hibernate.type.AbstractType
-
- org.hibernate.type.ComponentType
-
- org.hibernate.type.UserComponentType<T>
-
- All Implemented Interfaces:
Serializable,BindableType,OutputableType,CompositeType,ProcedureParameterExtractionAware,CompositeTypeImplementor,Type
public class UserComponentType<T> extends ComponentType
HandlesCompositeUserTypes.- Since:
- 6.3
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.hibernate.type.ComponentType
propertySpan
-
Fields inherited from class org.hibernate.type.AbstractType
LEGACY_DEFAULT_SIZE, LEGACY_DICTATED_SIZE
-
-
Constructor Summary
Constructors Constructor Description UserComponentType(Component component, int[] originalPropertyOrder, CompositeUserType<T> compositeUserType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectassemble(Serializable object, SharedSessionContractImplementor session, Object owner)Reconstruct the object from its disassembled state.ObjectdeepCopy(Object component, SessionFactoryImplementor factory)Return a deep copy of the persistent state, stopping at entities and at collections.Serializabledisassemble(Object value, SessionFactoryImplementor sessionFactory)Return a disassembled representation of the object.Serializabledisassemble(Object value, SharedSessionContractImplementor session, Object owner)Return a disassembled representation of the object.intgetHashCode(Object x)Get a hash code, consistent with persistence "equality".intgetHashCode(Object x, SessionFactoryImplementor factory)Get a hash code, consistent with persistence "equality".booleanisEqual(Object x, Object y)Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state.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.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.Objectreplace(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.ObjectreplacePropertyValues(Object component, Object[] values, SharedSessionContractImplementor session)Inject property values onto the given component instance, or return a new instance with the given property values.-
Methods inherited from class org.hibernate.type.ComponentType
canDoExtraction, compare, compare, extract, extract, getBindableJavaType, getCascadeStyle, getColumnSpan, getFetchMode, getJdbcType, getMappingModelPart, getName, getOnDeleteAction, getOriginalPropertyOrder, getPropertyIndex, getPropertyNames, getPropertyNullability, getPropertyValue, getPropertyValue, getPropertyValueGenerationStrategies, getPropertyValues, getPropertyValues, getReturnedClass, getSqlTypeCodes, getSubtypes, hasNotNullProperty, hasNullProperty, injectMappingModelPart, instantiator, isComponentType, isDirty, isDirty, isEmbedded, isKey, isMethodOf, isModified, isMutable, isSame, mappingModelPart, nullSafeSet, nullSafeSet, resolveExpressible, setPropertyValues, toColumnNullness, toLoggableString
-
Methods inherited from class org.hibernate.type.AbstractType
beforeAssemble, isAnyType, isAssociationType, isCollectionType, isEntityType
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.query.BindableType
isInstance
-
Methods inherited from interface org.hibernate.type.Type
beforeAssemble, getReturnedClassName, getTypeForEqualsHashCode, isAnyType, isAssociationType, isCollectionType, isEntityType
-
-
-
-
Constructor Detail
-
UserComponentType
public UserComponentType(Component component, int[] originalPropertyOrder, CompositeUserType<T> compositeUserType)
-
-
Method Detail
-
isEqual
public boolean isEqual(Object x, Object y) throws HibernateException
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 classComponentType- 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
-
isEqual
public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) throws HibernateException
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).- Specified by:
isEqualin interfaceType- Overrides:
isEqualin classComponentType- Parameters:
x- The first valuey- The second valuefactory- The session factory- Returns:
- True if there are considered equal (see discussion above).
- Throws:
HibernateException- A problem occurred performing the comparison
-
getHashCode
public int getHashCode(Object x)
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 classComponentType- Parameters:
x- The value for which to retrieve a hash code- Returns:
- The hash code
-
getHashCode
public int getHashCode(Object x, SessionFactoryImplementor factory)
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- Overrides:
getHashCodein classComponentType- Parameters:
x- The value for which to retrieve a hash codefactory- The session factory- Returns:
- The hash code
-
deepCopy
public Object deepCopy(Object component, SessionFactoryImplementor factory)
Description copied from interface:TypeReturn a deep copy of the persistent state, stopping at entities and at collections.- Specified by:
deepCopyin interfaceType- Overrides:
deepCopyin classComponentType- Parameters:
component- The value to be copiedfactory- The session factory- Returns:
- The deep copy
-
replace
public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object,Object> copyCache)
Description copied from interface:TypeDuring 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.- Specified by:
replacein interfaceType- Overrides:
replacein classComponentType- Parameters:
original- the value from the detached entity being mergedtarget- the value in the managed entitysession- The originating sessionowner- The owner of the valuecopyCache- The cache of already copied/replaced values- Returns:
- the value to be merged
-
replace
public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map<Object,Object> copyCache, ForeignKeyDirection foreignKeyDirection)
Description copied from interface:TypeDuring 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.- Specified by:
replacein interfaceType- Overrides:
replacein classComponentType- Parameters:
original- the value from the detached entity being mergedtarget- the value in the managed entitysession- The originating sessionowner- The owner of the valuecopyCache- The cache of already copied/replaced valuesforeignKeyDirection- For associations, which direction does the foreign key point?- Returns:
- the value to be merged
-
disassemble
public Serializable disassemble(Object value, SessionFactoryImplementor sessionFactory) throws HibernateException
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 classComponentType- Parameters:
value- the value to cachesessionFactory- the session factory- Returns:
- the disassembled, deep cloned state
- Throws:
HibernateException- An error from Hibernate
-
disassemble
public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException
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.
- Specified by:
disassemblein interfaceType- Overrides:
disassemblein classComponentType- Parameters:
value- the value to cachesession- the originating sessionowner- optional parent entity object (needed for collections)- Returns:
- the disassembled, deep cloned state
- Throws:
HibernateException- An error from Hibernate
-
assemble
public Object assemble(Serializable object, SharedSessionContractImplementor session, Object owner) throws HibernateException
Description copied from interface:TypeReconstruct the object from its disassembled state. This function is the inverse ofType.disassemble(Object, SharedSessionContractImplementor, Object).- Specified by:
assemblein interfaceType- Overrides:
assemblein classComponentType- Parameters:
object- the disassembled state from the cachesession- the originating sessionowner- the parent entity object- Returns:
- the (re)assembled object
- Throws:
HibernateException- An error from Hibernate
-
replacePropertyValues
public Object replacePropertyValues(Object component, Object[] values, SharedSessionContractImplementor session) throws HibernateException
Description copied from interface:CompositeTypeInject property values onto the given component instance, or return a new instance with the given property values.- Specified by:
replacePropertyValuesin interfaceCompositeType- Overrides:
replacePropertyValuesin classComponentType- Parameters:
component- The component instancevalues- The values to inject- Returns:
- A new instance as necessary
- Throws:
HibernateException- Indicates an issue performing the injection
-
-