@Override protected Argument build(String value, ConfigRegistry config) { return (pos, stmt, ctx) -> { PGobject obj = new PGobject(); obj.setType("macaddr"); obj.setValue(value); stmt.setObject(pos, obj); }; } }
private PGobject toPGobject(X value, WrapperOptions options) throws SQLException { final WkbEncoder encoder = Wkb.newEncoder( Wkb.Dialect.POSTGIS_EWKB_1 ); final Geometry geometry = getJavaDescriptor().unwrap( value, Geometry.class, options ); final String hexString = encoder.encode( geometry, ByteOrder.NDR ).toString(); final PGobject obj = new PGobject(); obj.setType( "geometry" ); obj.setValue( hexString ); return obj; }
Map<String, String> hstoreMap = new HashMap<>(); hstoreMap.put("key1", "value1"); hstoreMap.put("key2", "value2"); PGobject jsonbObj = new PGobject(); jsonbObj.setType("json"); jsonbObj.setValue("{\"key\" : \"value\"}");
/** * Construct and return Postgres specific PG object. */ public static Object asObject(String pgType, String rawJson) throws SQLException { PGobject pgo = new PGobject(); pgo.setType(pgType); pgo.setValue(rawJson); return pgo; } }
PGobject jsonObject = new PGobject(); jsonObject.setType("json"); jsonObject.setValue(yourJsonString); pstmt.setObject(11, jsonObject);
} else if (type.isMap()) { PGobject jsonObject = new PGobject(); jsonObject.setType("jsonb"); jsonObject.setValue(JsonHelper.encode(value)); ps.setObject(i + 1, jsonObject);
if (value instanceof Map) { PGobject jsonObject = new PGobject(); jsonObject.setType("jsonb"); jsonObject.setValue(JsonHelper.encode(value)); return jsonObject;
ObjectMapper objectMapper = new ObjectMapper(); PGobject jsonObject = new PGobject(); String Map_Json_String = objectMapper.writeValueAsString(your_map); jsonObject.setType("jsonb"); jsonObject.setValue(Map_Json_String); String final insertSql = "INSERT INTO \"Table_Name\"" + " VALUES (:jsonObject);";
/** * @param value Long value of ctid * @return PGObject instance * @throws SQLException */ public static PGobject longToTid(long value) throws SQLException { PGobject pGobject = new PGobject(); pGobject.setType("tid"); pGobject.setValue("(" + Long.toString(value >> 32)+","+Long.toString(value << 32 >> 32)+ ")"); return pGobject; }
@Override protected Argument build(String value, ConfigRegistry config) { return (pos, stmt, ctx) -> { PGobject obj = new PGobject(); obj.setType("macaddr"); obj.setValue(value); stmt.setObject(pos, obj); }; } }
PGobject toInsertUUID = new PGobject(); toInsertUUID.setType("uuid"); toInsertUUID.setValue(uuid.toString()); PreparedStmt stmt = conn.prepareStatement(query); stmt.setObject(placeHolder,toInsertUUID); stmt.execute();
/** * Construct and return Postgres specific PG object. */ public static Object asObject(String pgType, String rawJson) throws SQLException { PGobject pgo = new PGobject(); pgo.setType(pgType); pgo.setValue(rawJson); return pgo; } }
/** * Construct and return Postgres specific PG object. */ public static Object asObject(String pgType, String rawJson) throws SQLException { PGobject pgo = new PGobject(); pgo.setType(pgType); pgo.setValue(rawJson); return pgo; } }
@Override public Object serialize(String value) { PGobject pg = new PGobject(); pg.setType(getDataType()); try { pg.setValue(value); } catch (SQLException e) { // not thrown on base PGobject } return pg; }
@Override public Object serialize(String value) { PGobject pg = new PGobject(); pg.setType(getDataType()); try { pg.setValue(value); } catch (SQLException e) { // not thrown on base PGobject } return pg; }
@Override public Object serialize(String value) { PGobject pg = new PGobject(); pg.setType(getDataType()); try { pg.setValue(value); } catch (SQLException e) { // not thrown on base PGobject } return pg; }
@Override public Object serialize(String value) { PGobject pg = new PGobject(); pg.setType(getDataType()); try { pg.setValue(value); } catch (SQLException e) { // not thrown on base PGobject } return pg; }
@Override public void set(PreparedStatement st, IPv4 value, int index, SharedSessionContractImplementor session) throws SQLException { if (value == null) { st.setNull(index, Types.OTHER); } else { PGobject holder = new PGobject(); holder.setType("inet"); holder.setValue(value.getAddress()); st.setObject(index, holder); } } }