Class PostgreSQLIntervalType

java.lang.Object
io.hypersistence.utils.hibernate.type.ImmutableType<Duration>
io.hypersistence.utils.hibernate.type.interval.PostgreSQLIntervalType
All Implemented Interfaces:
Serializable, org.hibernate.type.Type, org.hibernate.usertype.EnhancedUserType<Duration>, org.hibernate.usertype.UserType<Duration>

public class PostgreSQLIntervalType extends ImmutableType<Duration>
Maps a Java Duration object to a PostgreSQL Interval column type.

For more details about how to use it, check out this article on vladmihalcea.com.

Since:
2.5.1
Author:
Jan-Willem Gmelig Meyling, Vlad Mihalcea
See Also:
  • Field Details

  • Constructor Details

    • PostgreSQLIntervalType

      public PostgreSQLIntervalType()
    • PostgreSQLIntervalType

      public PostgreSQLIntervalType(org.hibernate.type.spi.TypeBootstrapContext typeBootstrapContext)
  • Method Details

    • get

      protected Duration get(ResultSet rs, int position, org.hibernate.engine.spi.SharedSessionContractImplementor session, Object owner) throws SQLException
      Description copied from class: ImmutableType
      Get the column value from the JDBC ResultSet.
      Specified by:
      get in class ImmutableType<Duration>
      Parameters:
      rs - JDBC ResultSet
      position - database column position
      session - current Hibernate Session
      owner - current Hibernate SessionFactoryImplementor
      Returns:
      column value
      Throws:
      SQLException - in case of failure
    • set

      protected void set(PreparedStatement st, Duration value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor session) throws SQLException
      Description copied from class: ImmutableType
      Set the column value on the provided JDBC PreparedStatement.
      Specified by:
      set in class ImmutableType<Duration>
      Parameters:
      st - JDBC PreparedStatement
      value - database column value
      index - database column index
      session - current Hibernate Session
      Throws:
      SQLException - in case of failure
    • getSqlType

      public int getSqlType()
    • fromStringValue

      public Duration fromStringValue(CharSequence sequence) throws org.hibernate.HibernateException
      Throws:
      org.hibernate.HibernateException