org.hibernate.type.Type |
![]()
AbstractBynaryType,
AbstractCharArrayType,
AbstractComponentType,
AbstractLobType,
AbstractLongBinaryType,
AbstractLongStringType,
AbstractSingleColumnStandardBasicType<T>,
AbstractStandardBasicType<T>,
AbstractType,
AdaptedImmutableType<T>,
AnyType,
ArrayType,
AssociationType,
BagType,
BasicType,
and
75 others.
|
Defines a mapping between a Java type and one or more JDBC java.sql.Types types, as well as describing the in-memory semantics of the given java type (how do we check it for 'dirtiness', how do we copy values, etc).
Application developers needing custom types can implement this interface (either directly or via subclassing an existing impl) or by the (slightly more stable, though more limited)UserType
interface.
Implementations of this interface must certainly be thread-safe. It is recommended that they be immutable as
well, though that is difficult to achieve completely given the no-arg constructor requirement for custom types.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Reconstruct the object from its cached "disassembled" state.
| |||||||||||
Called before assembling a query result set from the query cache, to allow batch fetching
of entities missing from the second-level cache.
| |||||||||||
Perform a
Comparator style comparison between values | |||||||||||
Return a deep copy of the persistent state, stopping at entities and at
collections.
| |||||||||||
Return a cacheable "disassembled" representation of the object.
| |||||||||||
Parse the XML representation of an instance.
| |||||||||||
How many columns are used to persist this type.
| |||||||||||
Get a hash code, consistent with persistence "equality".
| |||||||||||
Get a hash code, consistent with persistence "equality".
| |||||||||||
Returns the abbreviated name of the type.
| |||||||||||
The class returned by
nullSafeGet(ResultSet, String, SessionImplementor, Object) methods. | |||||||||||
Get the type of a semi-resolved value.
| |||||||||||
Retrieve an instance of the mapped class, or the identifier of an entity or collection,
from a JDBC resultset.
| |||||||||||
Return true if the implementation is castable to
AnyType . | |||||||||||
Return true if the implementation is castable to
AssociationType . | |||||||||||
Return true if the implementation is castable to
CollectionType . | |||||||||||
Return true if the implementation is castable to
CompositeType . | |||||||||||
Should the parent be considered dirty, given both the old and current value?
| |||||||||||
Should the parent be considered dirty, given both the old and current value?
| |||||||||||
Return true if the implementation is castable to
EntityType . | |||||||||||
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
state).
| |||||||||||
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
state).
| |||||||||||
Has the value been modified compared to the current database state? The difference between this
and the
isDirty(Object, Object, boolean[], SessionImplementor) methods is that here we need to account for "partially" built values. | |||||||||||
Are objects of this type mutable.
| |||||||||||
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent
state) taking a shortcut for entity references.
| |||||||||||
Retrieve an instance of the mapped class from a JDBC resultset.
| |||||||||||
Retrieve an instance of the mapped class from a JDBC resultset.
| |||||||||||
Write an instance of the mapped class to a prepared statement, ignoring some columns.
| |||||||||||
Write an instance of the mapped class to a prepared statement.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Map identifiers to entities or collections.
| |||||||||||
Given a hydrated, but unresolved value, return a value that may be used to
reconstruct property-ref associations.
| |||||||||||
A representation of the value to be embedded in an XML element.
| |||||||||||
Return the JDBC types codes (per java.sql.Types) for the columns mapped by this type.
| |||||||||||
Given an instance of the type, return an array of boolean, indicating
which mapped columns would be null.
| |||||||||||
A representation of the value to be embedded in a log file.
|
Reconstruct the object from its cached "disassembled" state.
cached | the disassembled state from the cache |
---|---|
session | the session |
owner | the parent entity object |
HibernateException |
---|
Called before assembling a query result set from the query cache, to allow batch fetching of entities missing from the second-level cache.
Perform a Comparator
style comparison between values
x | The first value |
---|---|
y | The second value |
entityMode | The entity mode of the values. |
compare(T, T)
for a discussion.
Return a deep copy of the persistent state, stopping at entities and at collections.
value | generally a collection element or entity field |
---|
HibernateException |
---|
Return a cacheable "disassembled" representation of the object.
value | the value to cache |
---|---|
session | the session |
owner | optional parent entity object (needed for collections) |
HibernateException |
---|
Parse the XML representation of an instance.
HibernateException |
---|
How many columns are used to persist this type. Always the same as sqlTypes(mapping).length
mapping | The mapping object :/ |
---|
MappingException | Generally indicates an issue accessing the passed mapping object. |
---|
Get a hash code, consistent with persistence "equality". Again for most types the normal usage is to delegate to the value's #hashCode.
x | The value for which to retrieve a hash code |
---|---|
entityMode | The entity mode of the value. |
HibernateException | A problem occurred calculating the hash code |
---|
Get a hash code, consistent with persistence "equality". Again for most types the normal usage is to delegate to the value's #hashCode.
x | The value for which to retrieve a hash code |
---|---|
entityMode | The entity mode of the value. |
factory | The session factory |
HibernateException | A problem occurred calculating the hash code |
---|
Returns the abbreviated name of the type.
The class returned by nullSafeGet(ResultSet, String, SessionImplementor, Object)
methods. This is used to establish the class of an array of
this type.
Get the type of a semi-resolved value.
Retrieve an instance of the mapped class, or the identifier of an entity or collection, from a JDBC resultset. This is useful for 2-phase property initialization - the second phase is a call to resolveIdentifier().
names | the column names |
---|---|
session | the session |
owner | the parent entity |
HibernateException | |
SQLException | |
HibernateException |
Return true if the implementation is castable to AnyType
. Essentially a polymorphic
version of (type instanceof AnyType.class)
.
AnyType
is additionally an AssociationType
; so if this method returns true,
isAssociationType()
should also return true.AnyType
implementor; false otherwise.
Return true if the implementation is castable to AssociationType
. This does not necessarily imply that
the type actually represents an association. Essentially a polymorphic version of
(type instanceof AssociationType.class)
AssociationType
implementor; false otherwise.
Return true if the implementation is castable to CollectionType
. Essentially a polymorphic version of
(type instanceof CollectionType.class)
CollectionType
is additionally an AssociationType
; so if this method returns true,
isAssociationType()
should also return true.CollectionType
implementor; false otherwise.
Return true if the implementation is castable to CompositeType
. Essentially a polymorphic
version of (type instanceof CompositeType.class)
. A component type may own collections or
associations and hence must provide certain extra functionality.
CompositeType
implementor; false otherwise.
Should the parent be considered dirty, given both the old and current value?
oldState | the old value |
---|---|
currentState | the current value |
checkable | An array of booleans indicating which columns making up the value are actually checkable |
session | The session from which the request originated. |
HibernateException | A problem occurred performing the checking |
---|
Should the parent be considered dirty, given both the old and current value?
old | the old value |
---|---|
current | the current value |
session | The session from which the request originated. |
HibernateException | A problem occurred performing the checking |
---|
Return true if the implementation is castable to EntityType
. Essentially a polymorphic
version of (type instanceof EntityType.class)
.
EntityType
is additionally an AssociationType
; so if this method returns true,
isAssociationType()
should also return true.EntityType
implementor; false otherwise.
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent state).
This should always equate to some form of comparison of the value's internal state. As an example, for something like a date the comparison should be based on its internal "time" state based on the specific portion it is meant to represent (timestamp, date, time).x | The first value |
---|---|
y | The second value |
entityMode | The entity mode of the values. |
HibernateException | A problem occurred performing the comparison |
---|
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent state).
This should always equate to some form of comparison of the value's internal state. As an example, for something like a date the comparison should be based on its internal "time" state based on the specific portion it is meant to represent (timestamp, date, time).x | The first value |
---|---|
y | The second value |
entityMode | The entity mode of the values. |
factory | The session factory |
HibernateException | A problem occurred performing the comparison |
---|
Has the value been modified compared to the current database state? The difference between this
and the isDirty(Object, Object, boolean[], SessionImplementor)
methods is that here we need to account for "partially" built values. This is really
only an issue with association types. For most type implementations it is enough to simply delegate to
isDirty(Object, Object, boolean[], SessionImplementor)
here/
dbState | the database state, in a "hydrated" form, with identifiers unresolved |
---|---|
currentState | the current state of the object |
checkable | which columns are actually updatable |
session | The session from which the request originated. |
HibernateException | A problem occurred performing the checking |
---|
Are objects of this type mutable. (With respect to the referencing object ... entities and collections are considered immutable because they manage their own internal state.)
Compare two instances of the class mapped by this type for persistence "equality" (equality of persistent state) taking a shortcut for entity references.
For most types this should equate to #equals check on the values. For associations the implication is a bit different. For most types it is conceivable to simply delegate toisEqual(Object, Object, EntityMode)
x | The first value |
---|---|
y | The second value |
entityMode | The entity mode of the values. |
HibernateException | A problem occurred performing the comparison |
---|
Retrieve an instance of the mapped class from a JDBC resultset. Implementations should handle possibility of null values. This method might be called if the type is known to be a single-column type.
name | the column name |
---|---|
owner | the parent entity |
HibernateException | |
SQLException | |
HibernateException |
Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.
names | the column names |
---|---|
owner | the parent entity |
HibernateException | |
SQLException | |
HibernateException |
Write an instance of the mapped class to a prepared statement, ignoring some columns. Implementors should handle possibility of null values. A multi-column type should be written to parameters starting from index.
value | the object to write |
---|---|
index | statement parameter index |
settable | an array indicating which columns to ignore |
HibernateException | |
SQLException | |
HibernateException |
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 index.
value | the object to write |
---|---|
index | statement parameter index |
HibernateException | |
SQLException | |
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. For objects with component values, it might make sense to recursively replace component values.
original | the value from the detached entity being merged |
---|---|
target | the value in the managed entity |
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. For objects with component values, it might make sense to recursively replace component values.
original | the value from the detached entity being merged |
---|---|
target | the value in the managed entity |
HibernateException |
---|
Map identifiers to entities or collections. This is the second phase of 2-phase property initialization.
value | an identifier or value returned by hydrate() |
---|---|
session | the session |
owner | the parent entity |
HibernateException |
---|
Given a hydrated, but unresolved value, return a value that may be used to reconstruct property-ref associations.
HibernateException |
---|
A representation of the value to be embedded in an XML element.
HibernateException |
---|
Return the JDBC types codes (per java.sql.Types) for the columns mapped by this type.
mapping | The mapping object :/ |
---|
MappingException | Generally indicates an issue accessing the passed mapping object. |
---|
Given an instance of the type, return an array of boolean, indicating which mapped columns would be null.
value | an instance of the type |
---|
A representation of the value to be embedded in a log file.
HibernateException |
---|