Class PostgresPlugin

  • All Implemented Interfaces:
    JdbiPlugin

    public class PostgresPlugin
    extends JdbiPlugin.Singleton
    Postgres plugin. Adds support for binding and mapping the following data types:
    • InetAddress (including Inet4Address and Inet6Address)
    • LocalDate
    • LocalTime
    • LocalDateTime
    • OffsetDateTime
    • Duration (see notes below)
    • Period (see notes below)
    • Map<String, String> (for HSTORE columns)
    • UUID
    • InputStream and Reader from oid large object columns

    The following qualified types have Beta support for binding and mapping:

    Also sets up SQL array support for the following types:

    • double
    • float
    • int
    • long
    • Double
    • Float
    • Integer
    • Long
    • String
    • UUID

    A note about the mapping between the Postgres interval type and the Java Period and Duration types: The Java library authors are much more strict about the temporal amounts representable by Periods and Durations than Postgres is with its interval type. The argument factories and column mapper factories implemented in this package respect this spirit of unambiguous strictness. Consequently:

    • All Periods can be mapped to intervals.
    • Not all Durations can be mapped to intervals.
    • Not all intervals can be mapped to Periods.
    • Not all intervals can be mapped to Durations.
    For more specific detail, see the caveats in the documentation for DurationArgumentFactory, PeriodColumnMapperFactory, and DurationColumnMapperFactory.

    In addition, some potentially unexpected implicit conversions can occur by virtue of the Postgres server logic. For example, at the time of writing, storing a Period of -3 years, 2 months, and -1 days results in an interval (and consequently, a column-mapped Period) of -2 years, -10 months, and -1 days.

    • Field Detail

      • installLegacy

        private final boolean installLegacy
    • Constructor Detail

      • PostgresPlugin

        public PostgresPlugin()
      • PostgresPlugin

        protected PostgresPlugin​(boolean installLegacy)
    • Method Detail

      • noUnqualifiedHstoreBindings

        public static PostgresPlugin noUnqualifiedHstoreBindings()
        Do not install the legacy (unqualified) bindings for HStoreArgumentFactory and HStoreColumnMapper. When using the plugin returned by this factory method, any lookup for HStore specific arguments and column mappers must be qualified with the HStore annotation.
      • customizeJdbi

        public void customizeJdbi​(Jdbi jdbi)
        Description copied from interface: JdbiPlugin
        Configure customizations global to any object managed by this Jdbi. This method is invoked immediately when the plugin is installed.
        Parameters:
        jdbi - the jdbi to customize
      • customizeHandle

        public Handle customizeHandle​(Handle handle)
        Description copied from interface: JdbiPlugin
        Configure customizations for a new Handle instance.
        Parameters:
        handle - the handle just created
        Returns:
        the transformed handle