Java Code Examples for org.postgresql.util.PGobject#getType()

The following examples show how to use org.postgresql.util.PGobject#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return integerRange(value);
    } else if("int8range".equals(type)) {
        return longRange(value);
    } else if("numrange".equals(type)) {
        return bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 2
Source File: PostgreSQLRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return Range.integerRange(value);
    } else if("int8range".equals(type)) {
        return Range.longRange(value);
    } else if("numrange".equals(type)) {
        return Range.bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 3
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return integerRange(value);
    } else if("int8range".equals(type)) {
        return longRange(value);
    } else if("numrange".equals(type)) {
        return bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 4
Source File: PostgreSQLRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return Range.integerRange(value);
    } else if("int8range".equals(type)) {
        return Range.longRange(value);
    } else if("numrange".equals(type)) {
        return Range.bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 5
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return integerRange(value);
    } else if("int8range".equals(type)) {
        return longRange(value);
    } else if("numrange".equals(type)) {
        return bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 6
Source File: PostgreSQLRangeType.java    From hibernate-types with Apache License 2.0 6 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    if("int4range".equals(type)) {
        return Range.integerRange(value);
    } else if("int8range".equals(type)) {
        return Range.longRange(value);
    } else if("numrange".equals(type)) {
        return Range.bigDecimalRange(value);
    } else {
        throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 7
Source File: PostgreSQLGuavaRangeType.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    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 zonedDateTimeRange(value);
        case "daterange":
            return localDateRange(value);
        default:
            throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}
 
Example 8
Source File: PostgreSQLRangeType.java    From hibernate-types with Apache License 2.0 5 votes vote down vote up
@Override
protected Range get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException {
    PGobject pgObject = (PGobject) rs.getObject(names[0]);

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

    String type = pgObject.getType();
    String value = pgObject.getValue();

    switch (type) {
        case "int4range":
            return Range.integerRange(value);
        case "int8range":
            return Range.longRange(value);
        case "numrange":
            return Range.bigDecimalRange(value);
        case "tsrange":
            return Range.localDateTimeRange(value);
        case "tstzrange":
            return Range.zonedDateTimeRange(value);
        case "daterange":
            return Range.localDateRange(value);
        default:
            throw new IllegalStateException("The range type [" + type + "] is not supported!");
    }
}