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
HandlesCompositeUserType
s.- 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 Object
assemble(Serializable object, SharedSessionContractImplementor session, Object owner)
Reconstruct the object from its disassembled state.Object
deepCopy(Object component, SessionFactoryImplementor factory)
Return a deep copy of the persistent state, stopping at entities and at collections.Serializable
disassemble(Object value, SessionFactoryImplementor sessionFactory)
Return a disassembled representation of the object.Serializable
disassemble(Object value, SharedSessionContractImplementor session, Object owner)
Return a disassembled representation of the object.int
getHashCode(Object x)
Get a hash code, consistent with persistence "equality".int
getHashCode(Object x, SessionFactoryImplementor factory)
Get a hash code, consistent with persistence "equality".boolean
isEqual(Object x, Object y)
Compare two instances of the class mapped by this type for persistence "equality", that is, equality of persistent state.boolean
isEqual(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.Object
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.Object
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.Object
replacePropertyValues(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, 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, 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:Type
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 toequals()
.This should always equate to some form of comparison of the value's internal state. As an example, for Java's
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).- Specified by:
isEqual
in interfaceType
- Overrides:
isEqual
in 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:Type
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 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
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).- Specified by:
isEqual
in interfaceType
- Overrides:
isEqual
in 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:Type
Get a hash code, consistent with persistence "equality". For most types this could simply delegate to the given value'shashCode
.- Specified by:
getHashCode
in interfaceType
- Overrides:
getHashCode
in 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:Type
Get a hash code, consistent with persistence "equality". For most types this could simply delegate toType.getHashCode(Object)
.- Specified by:
getHashCode
in interfaceType
- Overrides:
getHashCode
in 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:Type
Return a deep copy of the persistent state, stopping at entities and at collections.- Specified by:
deepCopy
in interfaceType
- Overrides:
deepCopy
in 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:Type
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.- Specified by:
replace
in interfaceType
- Overrides:
replace
in 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:Type
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.- Specified by:
replace
in interfaceType
- Overrides:
replace
in 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:Type
Return 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:
disassemble
in interfaceType
- Overrides:
disassemble
in 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:Type
Return 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:
disassemble
in interfaceType
- Overrides:
disassemble
in 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:Type
Reconstruct the object from its disassembled state. This function is the inverse ofType.disassemble(Object, SharedSessionContractImplementor, Object)
.- Specified by:
assemble
in interfaceType
- Overrides:
assemble
in 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:CompositeType
Inject property values onto the given component instance, or return a new instance with the given property values.- Specified by:
replacePropertyValues
in interfaceCompositeType
- Overrides:
replacePropertyValues
in classComponentType
- Parameters:
component
- The component instancevalues
- The values to inject- Returns:
- A new instance as necessary
- Throws:
HibernateException
- Indicates an issue performing the injection
-
-