Class DurationArgumentFactory

java.lang.Object
org.jdbi.v3.core.argument.AbstractArgumentFactory<Duration>
org.jdbi.v3.postgres.DurationArgumentFactory
All Implemented Interfaces:
org.jdbi.v3.core.argument.ArgumentFactory, org.jdbi.v3.core.argument.ArgumentFactory.Preparable

public class DurationArgumentFactory extends org.jdbi.v3.core.argument.AbstractArgumentFactory<Duration>
Postgres version of argument factory for Duration.

For simplicity, this implementation makes the duration positive before proceeding. However, this can cause an ArithmeticException to be thrown. E.g., this can occur if your duration is -2^63 seconds.

Not all Durations can be represented as intervals in Postgres. One incompatibility results from Durations that are too large. This is due to (1) Durations using a long internally, and PGIntervals using ints; and (2) the conversion of days to months or years being ambiguous. Another results from Durations being too precise; they have nanosecond precision, whereas Postgres has only microsecond. An IllegalArgumentException will be thrown in these cases. The handling of the second is subject to revision in the future; for example, it would be reasonable to have a configurable truncation option.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.jdbi.v3.core.argument.ArgumentFactory

    org.jdbi.v3.core.argument.ArgumentFactory.Preparable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.jdbi.v3.core.argument.Argument
    build(Duration duration, org.jdbi.v3.core.config.ConfigRegistry config)
     

    Methods inherited from class org.jdbi.v3.core.argument.AbstractArgumentFactory

    build, prepare, prePreparedTypes

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DurationArgumentFactory

      public DurationArgumentFactory()
  • Method Details

    • build

      public org.jdbi.v3.core.argument.Argument build(Duration duration, org.jdbi.v3.core.config.ConfigRegistry config)