Package org.kiwiproject.jdbc.postgres
Class KiwiPostgres
java.lang.Object
org.kiwiproject.jdbc.postgres.KiwiPostgres
Utility functions related to Postgres DBs.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.postgresql.util.PGobjectnewJSONBObject(String jsonValue) Creates a newPGobjectof typeJSONB_TYPEwith the given JSON value.static org.postgresql.util.PGobjectnewJSONObject(String jsonValue) Creates a newPGobjectof typeJSON_TYPEwith the given JSON value.static org.postgresql.util.PGobjectnewPGobject(String type, String value) Creates a newPGobjectof the specified type and with the given value.
-
Field Details
-
JSON_TYPE
The Postgres "json" type.- See Also:
-
JSONB_TYPE
The Postgres "jsonb" type.- See Also:
-
-
Method Details
-
newJSONObject
Creates a newPGobjectof typeJSON_TYPEwith the given JSON value.- Parameters:
jsonValue- the JSON value as aString- Returns:
- a PGobject of type
jsonwith the given JSON string value
-
newJSONBObject
Creates a newPGobjectof typeJSONB_TYPEwith the given JSON value.- Parameters:
jsonValue- the JSON value as aString- Returns:
- a PGobject of type
jsonbwith the given JSON string value
-
newPGobject
Creates a newPGobjectof the specified type and with the given value.- Parameters:
type- the type of object, e.g. json or jsonbvalue- the value as a String- Returns:
- a new
PGobject - Implementation Note:
- We are catching the
SQLExceptionthrown byPGobject.setType(String)and wrapping with anIllegalStateExceptionsince this should never happen, since that specific setter method simply sets an instance field.
-