public final class DatetimeTzUserType
extends java.lang.Object
implements org.hibernate.usertype.CompositeUserType
P2J datetimetz
. This permits Hibernate to
convert this data type to and from the SQL TIMESTAMP and SMALLINT aggregate
data types. The unknown value is mapped to SQL NULL in the TIMESTAMP column.Modifier and Type | Field and Description |
---|---|
private static org.hibernate.type.Type[] |
HIBERNATE_TYPES
Two element array containing the HIBERNATE type being mapped.
|
Constructor and Description |
---|
DatetimeTzUserType() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
assemble(java.io.Serializable cached,
org.hibernate.engine.spi.SessionImplementor session,
java.lang.Object owner)
Reconstruct an object from the cacheable representation.
|
java.lang.Object |
deepCopy(java.lang.Object value)
Create and return a deep copy of the given
datetimetz instance. |
java.io.Serializable |
disassemble(java.lang.Object value,
org.hibernate.engine.spi.SessionImplementor session)
Transform the object into its cacheable representation.
|
boolean |
equals(java.lang.Object x,
java.lang.Object y)
Tests for equality between two data wrapper instances.
|
java.lang.String[] |
getPropertyNames()
Get the "property names" that may be used in a query.
|
org.hibernate.type.Type[] |
getPropertyTypes()
Get the corresponding "property types".
|
java.lang.Object |
getPropertyValue(java.lang.Object component,
int property)
Get the value of a property.
|
int |
hashCode(java.lang.Object x)
Get the hash code of the given object in a manner that is consistent with the equality check
performed by
equals(java.lang.Object, java.lang.Object) . |
boolean |
isMutable()
Returns
true to indicate that the P2J data wrapper object is mutable. |
java.lang.Object |
nullSafeGet(java.sql.ResultSet rs,
java.lang.String[] names,
org.hibernate.engine.spi.SessionImplementor sess,
java.lang.Object owner)
Retrieve an instance of the
datetimetz class from a JDBC resultset. |
void |
nullSafeSet(java.sql.PreparedStatement st,
java.lang.Object value,
int index,
org.hibernate.engine.spi.SessionImplementor sess)
Write an instance of the
datetimetz class to a prepared statement. |
java.lang.Object |
replace(java.lang.Object original,
java.lang.Object target,
org.hibernate.engine.spi.SessionImplementor session,
java.lang.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.
|
java.lang.Class |
returnedClass()
Gets the Java data type class mapped by this custom type.
|
void |
setPropertyValue(java.lang.Object component,
int property,
java.lang.Object value)
Set the value of a property.
|
private static final org.hibernate.type.Type[] HIBERNATE_TYPES
public java.lang.String[] getPropertyNames()
getPropertyNames
in interface org.hibernate.usertype.CompositeUserType
public org.hibernate.type.Type[] getPropertyTypes()
getPropertyTypes
in interface org.hibernate.usertype.CompositeUserType
public java.lang.Object getPropertyValue(java.lang.Object component, int property) throws org.hibernate.HibernateException
getPropertyValue
in interface org.hibernate.usertype.CompositeUserType
component
- An instance of class mapped by this "type".property
- Index of property to be returned.org.hibernate.HibernateException
public void setPropertyValue(java.lang.Object component, int property, java.lang.Object value) throws org.hibernate.HibernateException
setPropertyValue
in interface org.hibernate.usertype.CompositeUserType
component
- An instance of datetimetz class mapped by this "type".property
- Index of property to be set.value
- The value to set.org.hibernate.HibernateException
public boolean equals(java.lang.Object x, java.lang.Object y) throws org.hibernate.HibernateException
null
; OR
x.equals(y)
evaluates to true
.
This method is used by Hibernate for dirty checking.
equals
in interface org.hibernate.usertype.CompositeUserType
x
- A data wrapper type instance.y
- A data wrapper type instance.org.hibernate.HibernateException
public int hashCode(java.lang.Object x) throws org.hibernate.HibernateException
equals(java.lang.Object, java.lang.Object)
. This implementation simply returns the result of invoking
x.hashCode()
.hashCode
in interface org.hibernate.usertype.CompositeUserType
x
- A data wrapper type instance.org.hibernate.HibernateException
public java.lang.Object nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.spi.SessionImplementor sess, java.lang.Object owner) throws org.hibernate.HibernateException, java.sql.SQLException
datetimetz
class from a JDBC resultset.nullSafeGet
in interface org.hibernate.usertype.CompositeUserType
rs
- A JDBC result set.names
- The column names.sess
- The originating session.owner
- The containing entity.datetimetz
object.org.hibernate.HibernateException
java.sql.SQLException
- if a database access error occurs.public void nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index, org.hibernate.engine.spi.SessionImplementor sess) throws org.hibernate.HibernateException, java.sql.SQLException
datetimetz
class to a prepared statement.
A multi-column type should be written to parameters starting from index.nullSafeSet
in interface org.hibernate.usertype.CompositeUserType
st
- A JDBC prepared statement.value
- The object to be written.index
- The statement parameter index.sess
- org.hibernate.HibernateException
java.sql.SQLException
public boolean isMutable()
true
to indicate that the P2J data wrapper object is mutable.isMutable
in interface org.hibernate.usertype.CompositeUserType
true
.public java.io.Serializable disassemble(java.lang.Object value, org.hibernate.engine.spi.SessionImplementor session) throws org.hibernate.HibernateException
disassemble
in interface org.hibernate.usertype.CompositeUserType
value
- The object to be cached.session
- The originating session.org.hibernate.HibernateException
public java.lang.Object assemble(java.io.Serializable cached, org.hibernate.engine.spi.SessionImplementor session, java.lang.Object owner) throws org.hibernate.HibernateException
assemble
in interface org.hibernate.usertype.CompositeUserType
cached
- The object to be cached.session
- The originating session.owner
- The owner of the cached object.org.hibernate.HibernateException
public java.lang.Object replace(java.lang.Object original, java.lang.Object target, org.hibernate.engine.spi.SessionImplementor session, java.lang.Object owner) throws org.hibernate.HibernateException
replace
in interface org.hibernate.usertype.CompositeUserType
original
- The original object to be replaced.target
- The value in the managed entity.session
- The originating session.owner
- The owner of the value.datetimetz
is mutable, a deep copy of the
original
is returned.org.hibernate.HibernateException
- Is not thrown.public java.lang.Class returnedClass()
returnedClass
in interface org.hibernate.usertype.CompositeUserType
P2J datetimetz
class.public java.lang.Object deepCopy(java.lang.Object value)
datetimetz
instance.deepCopy
in interface org.hibernate.usertype.CompositeUserType
value
- The datetimetz
instance to be copied.datetimetz
which contains the
same internal value as value
.