Class PostgreSQLRangeType
- java.lang.Object
-
- com.vladmihalcea.hibernate.type.ImmutableType<Range>
-
- com.vladmihalcea.hibernate.type.range.PostgreSQLRangeType
-
- All Implemented Interfaces:
java.io.Serializable
,org.hibernate.type.Type
,org.hibernate.usertype.DynamicParameterizedType
,org.hibernate.usertype.ParameterizedType
,org.hibernate.usertype.UserType
public class PostgreSQLRangeType extends ImmutableType<Range> implements org.hibernate.usertype.DynamicParameterizedType
Maps aRange
object type to a PostgreSQL range column type.Supported range types:
- int4range
- int8range
- numrange
- tsrange
- tstzrange
- daterange
For more details about how to use it, check out this article on vladmihalcea.com.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PostgreSQLRangeType
INSTANCE
private java.lang.reflect.Type
type
-
Constructor Summary
Constructors Constructor Description PostgreSQLRangeType()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
determineRangeType(Range<?> range)
protected Range
get(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, java.lang.Object owner)
Get the column value from the JDBCResultSet
.java.lang.Class<?>
getElementType()
protected void
set(java.sql.PreparedStatement st, Range range, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session)
Set the column value on the provided JDBCPreparedStatement
.void
setParameterValues(java.util.Properties parameters)
int[]
sqlTypes()
-
Methods inherited from class com.vladmihalcea.hibernate.type.ImmutableType
assemble, assemble, beforeAssemble, compare, deepCopy, deepCopy, defaultSizes, dictatedSizes, disassemble, disassemble, equals, getColumnSpan, getConfiguration, getHashCode, getHashCode, getName, getReturnedClass, getSemiResolvedType, hashCode, hydrate, isAnyType, isAssociationType, isCollectionType, isComponentType, isDirty, isDirty, isDirty, isEntityType, isEqual, isEqual, isModified, isMutable, isSame, nullSafeGet, nullSafeGet, nullSafeSet, nullSafeSet, replace, replace, replace, resolve, returnedClass, semiResolve, sqlTypes, toColumnNullness, toLoggableString
-
-
-
-
Field Detail
-
INSTANCE
public static final PostgreSQLRangeType INSTANCE
-
type
private java.lang.reflect.Type type
-
-
Method Detail
-
sqlTypes
public int[] sqlTypes()
- Specified by:
sqlTypes
in interfaceorg.hibernate.usertype.UserType
-
get
protected Range get(java.sql.ResultSet rs, java.lang.String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, java.lang.Object owner) throws java.sql.SQLException
Description copied from class:ImmutableType
Get the column value from the JDBCResultSet
.- Specified by:
get
in classImmutableType<Range>
- Parameters:
rs
- JDBCResultSet
names
- database column namesession
- current HibernateSession
owner
- current HibernateSessionFactoryImplementor
- Returns:
- column value
- Throws:
java.sql.SQLException
- in case of failure
-
set
protected void set(java.sql.PreparedStatement st, Range range, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws java.sql.SQLException
Description copied from class:ImmutableType
Set the column value on the provided JDBCPreparedStatement
.- Specified by:
set
in classImmutableType<Range>
- Parameters:
st
- JDBCPreparedStatement
range
- database column valueindex
- database column indexsession
- current HibernateSession
- Throws:
java.sql.SQLException
- in case of failure
-
determineRangeType
private static java.lang.String determineRangeType(Range<?> range)
-
setParameterValues
public void setParameterValues(java.util.Properties parameters)
- Specified by:
setParameterValues
in interfaceorg.hibernate.usertype.ParameterizedType
-
getElementType
public java.lang.Class<?> getElementType()
-
-