public interface CompositeUserType
A <tt>UserType</tt> that may be dereferenced in a query. This interface allows a custom type to define "properties". These need not necessarily correspond to physical JavaBeans style properties.<br> <br> A <tt>CompositeUserType</tt> may be used in almost every way that a component may be used. It may even contain many-to-one associations.<br> <br> Implementors must be immutable and must declare a public default constructor.<br> <br> Unlike <tt>UserType</tt>, cacheability does not depend upon serializability. Instead, <tt>assemble()</tt> and <tt>disassemble</tt> provide conversion to/from a cacheable representation.
for more simple cases
,
Type
Modifier and Type | Method and Description |
---|---|
Object |
assemble(Serializable cached,
SharedSessionContractImplementor session,
Object owner)
Reconstruct an object from the cacheable representation.
|
Object |
deepCopy(Object value)
Return a deep copy of the persistent state, stopping at entities and at collections.
|
Serializable |
disassemble(Object value,
SharedSessionContractImplementor session)
Transform the object into its cacheable representation.
|
boolean |
equals(Object x,
Object y)
Compare two instances of the class mapped by this type for persistence "equality".
|
String[] |
getPropertyNames()
Get the "property names" that may be used in a
query.
|
Type[] |
getPropertyTypes()
Get the corresponding "property types".
|
Object |
getPropertyValue(Object component,
int property)
Get the value of a property.
|
int |
hashCode(Object x)
Get a hashcode for the instance, consistent with persistence "equality"
|
boolean |
isMutable()
Check if objects of this type mutable.
|
Object |
nullSafeGet(ResultSet rs,
String[] names,
SharedSessionContractImplementor session,
Object owner)
Retrieve an instance of the mapped class from a JDBC resultset.
|
void |
nullSafeSet(PreparedStatement st,
Object value,
int index,
SharedSessionContractImplementor session)
Write an instance of the mapped class to a prepared statement.
|
Object |
replace(Object original,
Object target,
SharedSessionContractImplementor session,
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.
|
Class |
returnedClass()
The class returned by <tt>nullSafeGet()</tt>.
|
void |
setPropertyValue(Object component,
int property,
Object value)
Set the value of a property.
|
String[] getPropertyNames()
Get the "property names" that may be used in a query.
Type[] getPropertyTypes()
Get the corresponding "property types".
Object getPropertyValue(Object component, int property) throws HibernateException
Get the value of a property.
component
- an instance of class mapped by this "type"property
- HibernateException
void setPropertyValue(Object component, int property, Object value) throws HibernateException
Set the value of a property.
component
- an instance of class mapped by this "type"property
- value
- the value to setHibernateException
Class returnedClass()
The class returned by <tt>nullSafeGet()</tt>.
boolean equals(Object x, Object y) throws HibernateException
Compare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.
HibernateException
int hashCode(Object x) throws HibernateException
Get a hashcode for the instance, consistent with persistence "equality"
HibernateException
Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException
Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.
rs
- a JDBC result setnames
- the column namessession
- owner
- the containing entityHibernateException
SQLException
void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, 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 <tt>index</tt>.
st
- a JDBC prepared statementvalue
- the object to writeindex
- statement parameter indexsession
- HibernateException
SQLException
Object deepCopy(Object value) throws HibernateException
Return a deep copy of the persistent state, stopping at entities and at collections.
value
- generally a collection element or entity fieldHibernateException
boolean isMutable()
Check if objects of this type mutable.
Serializable disassemble(Object value, SharedSessionContractImplementor session) throws HibernateException
Transform the object into its cacheable representation. At the very least this method should perform a deep copy. That may not be enough for some implementations, however; for example, associations must be cached as identifier values. (optional operation)
value
- the object to be cachedsession
- HibernateException
Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException
Reconstruct an object from the cacheable representation. At the very least this method should perform a deep copy. (optional operation)
cached
- the object to be cachedsession
- owner
- the owner of the cached objectHibernateException
Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner) throws HibernateException
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. However, since composite user types often define component values, it might make sense to recursively replace component values in the target object.
HibernateException
Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.