public class PostgreSQLGuavaRangeType extends ImmutableType<com.google.common.collect.Range> implements org.hibernate.usertype.DynamicParameterizedType
Range
object type to a PostgreSQL range
column type.
Supported range types:
Modifier and Type | Field and Description |
---|---|
static PostgreSQLGuavaRangeType |
INSTANCE |
Constructor and Description |
---|
PostgreSQLGuavaRangeType() |
PostgreSQLGuavaRangeType(Class<?> elementType) |
Modifier and Type | Method and Description |
---|---|
String |
asString(com.google.common.collect.Range range) |
static com.google.common.collect.Range<BigDecimal> |
bigDecimalRange(String range)
Creates the
BigDecimal range from provided string: |
protected com.google.common.collect.Range |
get(ResultSet rs,
String[] names,
org.hibernate.engine.spi.SharedSessionContractImplementor session,
Object owner)
Get the column value from the JDBC
ResultSet . |
Class<?> |
getElementType() |
static com.google.common.collect.Range<Integer> |
integerRange(String range)
Creates the
Integer range from provided string: |
static com.google.common.collect.Range<LocalDate> |
localDateRange(String range)
Creates the
LocalDate range from provided string: |
static com.google.common.collect.Range<LocalDateTime> |
localDateTimeRange(String range)
Creates the
LocalDateTime range from provided string: |
static com.google.common.collect.Range<Long> |
longRange(String range)
Creates the
Long range from provided string: |
static com.google.common.collect.Range<OffsetDateTime> |
offsetDateTimeRange(String rangeStr)
Creates the
OffsetDateTime range from provided string: |
static <T extends Comparable<?>> |
ofString(String str,
Function<String,T> converter,
Class<T> clazz) |
protected void |
set(PreparedStatement st,
com.google.common.collect.Range range,
int index,
org.hibernate.engine.spi.SharedSessionContractImplementor session)
Set the column value on the provided JDBC
PreparedStatement . |
void |
setParameterValues(Properties parameters) |
int[] |
sqlTypes() |
static com.google.common.collect.Range<ZonedDateTime> |
zonedDateTimeRange(String rangeStr)
Creates the
ZonedDateTime range from provided string: |
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
public static final PostgreSQLGuavaRangeType INSTANCE
public PostgreSQLGuavaRangeType()
public PostgreSQLGuavaRangeType(Class<?> elementType)
public int[] sqlTypes()
sqlTypes
in interface org.hibernate.usertype.UserType
protected com.google.common.collect.Range get(ResultSet rs, String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
ImmutableType
ResultSet
.get
in class ImmutableType<com.google.common.collect.Range>
rs
- JDBC ResultSet
names
- database column namesession
- current Hibernate Session
owner
- current Hibernate SessionFactoryImplementor
SQLException
- in case of failureprotected void set(PreparedStatement st, com.google.common.collect.Range range, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
ImmutableType
PreparedStatement
.set
in class ImmutableType<com.google.common.collect.Range>
st
- JDBC PreparedStatement
range
- database column valueindex
- database column indexsession
- current Hibernate Session
SQLException
- in case of failurepublic static <T extends Comparable<?>> com.google.common.collect.Range<T> ofString(String str, Function<String,T> converter, Class<T> clazz)
public static com.google.common.collect.Range<BigDecimal> bigDecimalRange(String range)
BigDecimal
range from provided string:
Range<BigDecimal> closed = Range.bigDecimalRange("[0.1,1.1]");
Range<BigDecimal> halfOpen = Range.bigDecimalRange("(0.1,1.1]");
Range<BigDecimal> open = Range.bigDecimalRange("(0.1,1.1)");
Range<BigDecimal> leftUnbounded = Range.bigDecimalRange("(,1.1)");
range
- The range string, for example "[5.5,7.8]".BigDecimal
s.NumberFormatException
- when one of the bounds are invalid.public static com.google.common.collect.Range<Integer> integerRange(String range)
Integer
range from provided string:
Range<Integer> closed = Range.integerRange("[1,5]");
Range<Integer> halfOpen = Range.integerRange("(-1,1]");
Range<Integer> open = Range.integerRange("(1,2)");
Range<Integer> leftUnbounded = Range.integerRange("(,10)");
Range<Integer> unbounded = Range.integerRange("(,)");
range
- The range string, for example "[5,7]".Integer
s.NumberFormatException
- when one of the bounds are invalid.public static com.google.common.collect.Range<Long> longRange(String range)
Long
range from provided string:
Range<Long> closed = Range.longRange("[1,5]");
Range<Long> halfOpen = Range.longRange("(-1,1]");
Range<Long> open = Range.longRange("(1,2)");
Range<Long> leftUnbounded = Range.longRange("(,10)");
Range<Long> unbounded = Range.longRange("(,)");
range
- The range string, for example "[5,7]".Long
s.NumberFormatException
- when one of the bounds are invalid.public static com.google.common.collect.Range<LocalDateTime> localDateTimeRange(String range)
LocalDateTime
range from provided string:
Range<LocalDateTime> closed = Range.localDateTimeRange("[2014-04-28 16:00:49,2015-04-28 16:00:49]");
Range<LocalDateTime> quoted = Range.localDateTimeRange("[\"2014-04-28 16:00:49\",\"2015-04-28 16:00:49\"]");
Range<LocalDateTime> iso = Range.localDateTimeRange("[\"2014-04-28T16:00:49.2358\",\"2015-04-28T16:00:49\"]");
The valid formats for bounds are:
range
- The range string, for example "[2014-04-28 16:00:49,2015-04-28 16:00:49]".LocalDateTime
s.DateTimeParseException
- when one of the bounds are invalid.public static com.google.common.collect.Range<LocalDate> localDateRange(String range)
LocalDate
range from provided string:
Range<LocalDate> closed = Range.localDateRange("[2014-04-28,2015-04-289]");
Range<LocalDate> quoted = Range.localDateRange("[\"2014-04-28\",\"2015-04-28\"]");
Range<LocalDate> iso = Range.localDateRange("[\"2014-04-28\",\"2015-04-28\"]");
The valid formats for bounds are:
range
- The range string, for example "[2014-04-28,2015-04-28]".LocalDate
s.DateTimeParseException
- when one of the bounds are invalid.public static com.google.common.collect.Range<ZonedDateTime> zonedDateTimeRange(String rangeStr)
ZonedDateTime
range from provided string:
Range<ZonedDateTime> closed = Range.zonedDateTimeRange("[2007-12-03T10:15:30+01:00\",\"2008-12-03T10:15:30+01:00]");
Range<ZonedDateTime> quoted = Range.zonedDateTimeRange("[\"2007-12-03T10:15:30+01:00\",\"2008-12-03T10:15:30+01:00\"]");
Range<ZonedDateTime> iso = Range.zonedDateTimeRange("[2011-12-03T10:15:30+01:00[Europe/Paris], 2012-12-03T10:15:30+01:00[Europe/Paris]]");
The valid formats for bounds are:
rangeStr
- The range string, for example "[2011-12-03T10:15:30+01:00,2012-12-03T10:15:30+01:00]".ZonedDateTime
s.DateTimeParseException
- when one of the bounds are invalid.IllegalArgumentException
- when bounds time zones are different.public static com.google.common.collect.Range<OffsetDateTime> offsetDateTimeRange(String rangeStr)
OffsetDateTime
range from provided string:
Range<OffsetDateTime> closed = Range.offsetDateTimeRange("[2007-12-03T10:15:30+01:00\",\"2008-12-03T10:15:30+01:00]");
Range<OffsetDateTime> quoted = Range.offsetDateTimeRange("[\"2007-12-03T10:15:30+01:00\",\"2008-12-03T10:15:30+01:00\"]");
Range<OffsetDateTime> iso = Range.offsetDateTimeRange("[2011-12-03T10:15:30+01:00[Europe/Paris], 2012-12-03T10:15:30+01:00[Europe/Paris]]");
The valid formats for bounds are:
rangeStr
- The range string, for example "[2011-12-03T10:15:30+01:00,2012-12-03T10:15:30+01:00]".OffsetDateTime
s.DateTimeParseException
- when one of the bounds are invalid.IllegalArgumentException
- when bounds time zones are different.public String asString(com.google.common.collect.Range range)
public void setParameterValues(Properties parameters)
setParameterValues
in interface org.hibernate.usertype.ParameterizedType
public Class<?> getElementType()
Copyright © 2021. All rights reserved.