I'm trying to persist a postgres POINT(x,y) using a custom data persister but ORMLite insists on wrapping my value with quotation marks, which Postgres rejects.
Error i'm getting from the DB:
ERROR: invalid input syntax for type point: "POINT(-115.17913055419922,36.08929443359375)"
Here is how it should look in SQL:
INSERT INTO somegeometries values (POINT(-119.234,36.089))
Here is the important part of the persister:
public PGpointDataPersister() {
super(SqlType.OTHER, new Class[] {PGpoint.class});
}
public Object javaToSqlArg(FieldType fieldType, Object javaObject) throws SQLException {
if (javaObject == null) {
return null;
}
PGpoint pt = (PGpoint) javaObject;
return "POINT(" + pt.x + "," + pt.y + ")";
}
According to Postgresql's documentation this should be supported in the JDBC driver. See https://jdbc.postgresql.org/documentation/80/geometric.html.
I'm using ORMLite 4.48 and the official postgresql JDBC4 driver.
How can i make this work?