Class ImmutableType<T>
java.lang.Object
io.hypersistence.utils.hibernate.type.ImmutableType<T>
- All Implemented Interfaces:
Serializable,org.hibernate.type.Type,org.hibernate.usertype.EnhancedUserType<T>,org.hibernate.usertype.UserType<T>
- Direct Known Subclasses:
DescriptorImmutableType,ImmutableDynamicParameterizedType,NullableCharacterType,OracleIntervalDayToSecondType,PostgreSQLCITextType,PostgreSQLGuavaRangeType,PostgreSQLHStoreType,PostgreSQLInetType,PostgreSQLIntervalType,PostgreSQLLTreeType,PostgreSQLPeriodType,PostgreSQLRangeType,PostgreSQLSpringRangeType
public abstract class ImmutableType<T>
extends Object
implements org.hibernate.usertype.UserType<T>, org.hibernate.type.Type, org.hibernate.usertype.EnhancedUserType<T>
Very convenient base class for implementing immutable object types using Hibernate
UserType.
The ImmutableType implements the Type interface too, so you can pass all
types extending the ImmutableType to the NativeQuery.addScalar(String, BasicDomainType)
method to fix the No Dialect mapping for JDBC type issues.
- Author:
- Vlad Mihalcea
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedImmutableType(Class<T> clazz) Initialization constructor taking theClassand using the defaultConfigurationobject.protectedImmutableType(Class<T> clazz, Configuration configuration) Initialization constructor taking theClassandConfigurationobjects. -
Method Summary
Modifier and TypeMethodDescriptionassemble(Serializable cached, Object owner) assemble(Serializable cached, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) voidbeforeAssemble(Serializable cached, org.hibernate.engine.spi.SharedSessionContractImplementor session) intintcompare(Object x, Object y, org.hibernate.engine.spi.SessionFactoryImplementor sessionFactoryImplementor) disassemble(Object value, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) booleanprotected abstract Tget(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) Get the column value from the JDBCResultSet.intgetColumnSpan(org.hibernate.engine.spi.Mapping mapping) protected ConfigurationGet the currentConfigurationobject.intintgetHashCode(Object x, org.hibernate.engine.spi.SessionFactoryImplementor factory) getName()int[]getSqlTypeCodes(org.hibernate.engine.spi.Mapping mapping) intbooleanbooleanbooleanbooleanprotected final booleanfinal booleanisDirty(Object old, Object current, boolean[] checkable, org.hibernate.engine.spi.SharedSessionContractImplementor session) final booleanisDirty(Object old, Object current, org.hibernate.engine.spi.SharedSessionContractImplementor session) booleanbooleanbooleanbooleanisModified(Object dbState, Object currentState, boolean[] checkable, org.hibernate.engine.spi.SharedSessionContractImplementor session) booleanbooleannullSafeGet(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) voidnullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, org.hibernate.engine.spi.SharedSessionContractImplementor session) voidnullSafeSet(PreparedStatement st, Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) replace(Object original, Object target, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner, Map copyCache) replace(Object original, Object target, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner, Map copyCache, org.hibernate.type.ForeignKeyDirection foreignKeyDirection) protected abstract voidset(PreparedStatement st, T value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) Set the column value on the provided JDBCPreparedStatement.boolean[]toColumnNullness(Object value, org.hibernate.engine.spi.Mapping mapping) toLoggableString(Object value, org.hibernate.engine.spi.SessionFactoryImplementor factory) toSqlLiteral(T o) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.usertype.EnhancedUserType
fromStringValueMethods inherited from interface org.hibernate.type.Type
disassembleMethods inherited from interface org.hibernate.usertype.UserType
getDefaultSqlLength, getDefaultSqlPrecision, getDefaultSqlScale, getJdbcType, getSqlType, getValueConverter
-
Constructor Details
-
ImmutableType
Initialization constructor taking theClassand using the defaultConfigurationobject.- Parameters:
clazz- the entity attributeClasstype to be handled
-
ImmutableType
Initialization constructor taking theClassandConfigurationobjects.- Parameters:
clazz- the entity attributeClasstype to be handledconfiguration- customConfigurationobject.
-
-
Method Details
-
getConfiguration
Get the currentConfigurationobject.- Returns:
- the current
Configurationobject.
-
returnedClass
- Specified by:
returnedClassin interfaceorg.hibernate.usertype.UserType<T>
-
equals
- Specified by:
equalsin interfaceorg.hibernate.usertype.UserType<T>
-
hashCode
- Specified by:
hashCodein interfaceorg.hibernate.usertype.UserType<T>
-
deepCopy
- Specified by:
deepCopyin interfaceorg.hibernate.usertype.UserType<T>
-
isMutable
public boolean isMutable()- Specified by:
isMutablein interfaceorg.hibernate.type.Type- Specified by:
isMutablein interfaceorg.hibernate.usertype.UserType<T>
-
disassemble
- Specified by:
disassemblein interfaceorg.hibernate.usertype.UserType<T>
-
assemble
- Specified by:
assemblein interfaceorg.hibernate.usertype.UserType<T>
-
replace
- Specified by:
replacein interfaceorg.hibernate.usertype.UserType<T>
-
isAssociationType
public boolean isAssociationType()- Specified by:
isAssociationTypein interfaceorg.hibernate.type.Type
-
isCollectionType
public boolean isCollectionType()- Specified by:
isCollectionTypein interfaceorg.hibernate.type.Type
-
isEntityType
public boolean isEntityType()- Specified by:
isEntityTypein interfaceorg.hibernate.type.Type
-
isAnyType
public boolean isAnyType()- Specified by:
isAnyTypein interfaceorg.hibernate.type.Type
-
isComponentType
public boolean isComponentType()- Specified by:
isComponentTypein interfaceorg.hibernate.type.Type
-
getColumnSpan
public int getColumnSpan(org.hibernate.engine.spi.Mapping mapping) throws org.hibernate.MappingException - Specified by:
getColumnSpanin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.MappingException
-
getReturnedClass
- Specified by:
getReturnedClassin interfaceorg.hibernate.type.Type
-
isSame
- Specified by:
isSamein interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
isEqual
- Specified by:
isEqualin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
isEqual
public boolean isEqual(Object x, Object y, org.hibernate.engine.spi.SessionFactoryImplementor factory) throws org.hibernate.HibernateException - Specified by:
isEqualin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
getHashCode
- Specified by:
getHashCodein interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
getHashCode
public int getHashCode(Object x, org.hibernate.engine.spi.SessionFactoryImplementor factory) throws org.hibernate.HibernateException - Specified by:
getHashCodein interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
compare
public int compare(Object x, Object y, org.hibernate.engine.spi.SessionFactoryImplementor sessionFactoryImplementor) - Specified by:
comparein interfaceorg.hibernate.type.Type
-
compare
- Specified by:
comparein interfaceorg.hibernate.type.Type
-
isDirty
-
toLoggableString
public String toLoggableString(Object value, org.hibernate.engine.spi.SessionFactoryImplementor factory) throws org.hibernate.HibernateException - Specified by:
toLoggableStringin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
getName
- Specified by:
getNamein interfaceorg.hibernate.type.Type
-
deepCopy
public Object deepCopy(Object value, org.hibernate.engine.spi.SessionFactoryImplementor factory) throws org.hibernate.HibernateException - Specified by:
deepCopyin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.HibernateException
-
toColumnNullness
- Specified by:
toColumnNullnessin interfaceorg.hibernate.type.Type
-
getSqlTypeCodes
public int[] getSqlTypeCodes(org.hibernate.engine.spi.Mapping mapping) throws org.hibernate.MappingException - Specified by:
getSqlTypeCodesin interfaceorg.hibernate.type.Type- Throws:
org.hibernate.MappingException
-
toSqlLiteral
- Specified by:
toSqlLiteralin interfaceorg.hibernate.usertype.EnhancedUserType<T>
-
toString
- Specified by:
toStringin interfaceorg.hibernate.usertype.EnhancedUserType<T>- Throws:
org.hibernate.HibernateException
-