@Override
    protected Range get(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException {
        Object pgObject = rs.getObject(position);

        if (pgObject == null) {
            return null;
        }

        String type = ReflectionUtils.invokeGetter(pgObject, "type");
        String value = ReflectionUtils.invokeGetter(pgObject, "value");

        switch (type) {
            case "int4range":
                return integerRange(value);
            case "int8range":
                return longRange(value);
            case "numrange":
                return bigDecimalRange(value);
            case "tsrange":
                return localDateTimeRange(value);
            case "tstzrange":
                return ZonedDateTime.class.equals(elementType) ? zonedDateTimeRange(value) : offsetDateTimeRange(value);
            case "daterange":
                return localDateRange(value);
            default:
                throw new HibernateException(
                        new IllegalStateException("The range type [" + type + "] is not supported!")
                );
        }
    }
@Test
    public void test() {
        Restriction ageRestrictionInt = doInJPA(entityManager -> {
            entityManager.persist(new Restriction());

            Restriction restriction = new Restriction();
            restriction.setRangeInt(int4Range);
            restriction.setRangeIntEmpty(int4RangeEmpty);
            restriction.setRangeLong(int8Range);
            restriction.setRangeLongEmpty(int8RangeEmpty);
            restriction.setRangeBigDecimal(numeric);
            restriction.setRangeBigDecimalEmpty(numericEmpty);
            restriction.setRangeLocalDateTime(localDateTimeRange);
            restriction.setRangeLocalDateTimeEmpty(localDateTimeRangeEmpty);
            restriction.setRangeZonedDateTime(tsTz);
            restriction.setRangeZonedDateTimeEmpty(tsTzEmpty);
            restriction.setRangeLocalDate(dateRange);
            restriction.setRangeLocalDateEmpty(dateRangeEmpty);
            restriction.setOffsetZonedDateTime(tsTzO);
            entityManager.persist(restriction);

            return restriction;
        });

        doInJPA(entityManager -> {
            Restriction ar = entityManager.find(Restriction.class, ageRestrictionInt.getId());

            assertEquals(int4Range, ar.getRangeInt());
            assertEquals(int4RangeEmpty, ar.getRangeIntEmpty());
            assertEquals(int8Range, ar.getRangeLong());
            assertEquals(int8RangeEmpty, ar.getRangeLongEmpty());
            assertEquals(numeric, ar.getRangeBigDecimal());
            assertEquals(numericEmpty, ar.getRangeBigDecimalEmpty());
            assertEquals(localDateTimeRange, ar.getRangeLocalDateTime());
            assertEquals(localDateTimeRangeEmpty, ar.getRangeLocalDateTimeEmpty());
            assertEquals(tsTzO, ar.getOffsetZonedDateTime());
            assertEquals(dateRange, ar.getRangeLocalDate());
            assertEquals(dateRangeEmpty, ar.getRangeLocalDateEmpty());

            ZoneId zone = ar.getRangeZonedDateTime().getLowerBound().getValue().get().getZone();
            ZonedDateTime lower = tsTz.getLowerBound().getValue().get().withZoneSameInstant(zone);
            ZonedDateTime upper = tsTz.getUpperBound().getValue().get().withZoneSameInstant(zone);
            assertEquals(ar.getRangeZonedDateTime(), Range.rightOpen(lower, upper));

            ZoneId zoneEmpty = ar.getRangeZonedDateTimeEmpty().getLowerBound().getValue().get().getZone();
            ZonedDateTime lowerEmpty = tsTzEmpty.getLowerBound().getValue().get().withZoneSameInstant(zoneEmpty);
            ZonedDateTime upperEmpty = tsTzEmpty.getUpperBound().getValue().get().withZoneSameInstant(zoneEmpty);
            assertEquals(ar.getRangeZonedDateTimeEmpty(), Range.rightOpen(lowerEmpty, upperEmpty));

        });
    }