diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java new file mode 100644 index 000000000..59fb4bb90 --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/api/GeoTypeProvider.java @@ -0,0 +1,15 @@ +package io.ebeaninternal.api; + +import io.ebean.config.DatabaseConfig; +import io.ebeaninternal.server.type.GeoTypeBinder; + +/** + * Provider of Geometry type binder support. + */ +public interface GeoTypeProvider { + + /** + * Create a binder for binding geometry types. + */ + GeoTypeBinder createBinder(DatabaseConfig config); +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/persist/Binder.java b/ebean-core/src/main/java/io/ebeaninternal/server/persist/Binder.java index 29c5032d9..9865eee9d 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/persist/Binder.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/persist/Binder.java @@ -8,6 +8,7 @@ import io.ebeaninternal.server.expression.platform.DbExpressionHandler; import io.ebeaninternal.server.persist.platform.MultiValueBind; import io.ebeaninternal.server.type.DataBind; import io.ebeaninternal.server.type.DataReader; +import io.ebeaninternal.server.type.GeoTypeBinder; import io.ebeaninternal.server.type.PostgresHelper; import io.ebeaninternal.server.type.RsetDataReader; import io.ebeaninternal.server.type.ScalarType; @@ -35,26 +36,18 @@ public class Binder { private static final Logger logger = LoggerFactory.getLogger(Binder.class); private final TypeManager typeManager; - private final int asOfBindCount; - private final boolean asOfStandardsBased; - private final DbExpressionHandler dbExpressionHandler; - private final DataTimeZone dataTimeZone; - private final MultiValueBind multiValueBind; - private final boolean enableBindLog; + private final GeoTypeBinder geoTypeBinder; - /** - * Set the PreparedStatement with which to bind variables to. - */ public Binder(TypeManager typeManager, SpiLogManager logManager, int asOfBindCount, boolean asOfStandardsBased, DbExpressionHandler dbExpressionHandler, DataTimeZone dataTimeZone, MultiValueBind multiValueBind) { - this.typeManager = typeManager; + this.geoTypeBinder = typeManager.getGeoTypeBinder(); this.asOfBindCount = asOfBindCount; this.asOfStandardsBased = asOfStandardsBased; this.dbExpressionHandler = dbExpressionHandler; @@ -88,9 +81,7 @@ public class Binder { * Bind the values to the Prepared Statement. */ public void bind(BindValues bindValues, DataBind dataBind, StringBuilder bindBuf) throws SQLException { - String logPrefix = ""; - ArrayList list = bindValues.values(); for (BindValues.Value bindValue : list) { Object val = bindValue.getValue(); @@ -124,7 +115,6 @@ public class Binder { * Bind the list of positionedParameters in BindParams. */ private String bind(BindParams bindParams, DataBind dataBind) throws SQLException { - StringBuilder bindLog = new StringBuilder(); bind(bindParams, dataBind, bindLog); return bindLog.toString(); @@ -134,7 +124,6 @@ public class Binder { * Bind the list of positionedParameters in BindParams. */ public void bind(BindParams bindParams, DataBind dataBind, StringBuilder bindLog) throws SQLException { - bind(bindParams.positionedParameters(), dataBind, bindLog); } @@ -142,13 +131,10 @@ public class Binder { * Bind the list of parameters.. */ private void bind(List list, DataBind dataBind, StringBuilder bindLog) throws SQLException { - CallableStatement cstmt = null; - if (dataBind.getPstmt() instanceof CallableStatement) { cstmt = (CallableStatement) dataBind.getPstmt(); } - // the iterator is assumed to be in the correct order Object value = null; try { @@ -211,7 +197,6 @@ public class Binder { * Bind an Object with unknown data type. */ public Object bindObject(DataBind dataBind, Object value) throws SQLException { - if (value == null) { // null of unknown type bindObject(dataBind, null, Types.OTHER); @@ -233,9 +218,7 @@ public class Binder { // convert to a JDBC native type value = type.toJdbcType(value); } - - int dbType = type.getJdbcType(); - bindObject(dataBind, value, dbType); + bindObject(dataBind, value, type.getJdbcType()); return value; } } @@ -261,12 +244,10 @@ public class Binder { *

*/ private void bindObject(DataBind dataBind, Object data, int dbType) throws SQLException { - if (data == null) { dataBind.setNull(dbType); return; } - switch (dbType) { case java.sql.Types.LONGVARCHAR: bindLongVarChar(dataBind, data); @@ -293,7 +274,6 @@ public class Binder { * Binds the value to the statement according to the data type. */ private void bindSimpleData(DataBind b, int dataType, Object data) { - try { switch (dataType) { case java.sql.Types.BOOLEAN: @@ -370,6 +350,15 @@ public class Binder { b.setObject(PostgresHelper.asInet(data.toString())); break; + case DbPlatformType.POINT: + case DbPlatformType.POLYGON: + case DbPlatformType.MULTIPOINT: + case DbPlatformType.LINESTRING: + case DbPlatformType.MULTILINESTRING: + case DbPlatformType.MULTIPOLYGON: + geoTypeBinder.bind(b, dataType, data); + break; + case java.sql.Types.OTHER: b.setObject(data, dataType); break; @@ -393,7 +382,6 @@ public class Binder { * Bind String data to a LONGVARCHAR column. */ private void bindLongVarChar(DataBind dataBind, Object data) throws SQLException { - dataBind.setClob((String) data); } @@ -401,7 +389,6 @@ public class Binder { * Bind byte[] data to a LONGVARBINARY column. */ private void bindLongVarBinary(DataBind dataBind, Object data) throws SQLException { - dataBind.setBlob((byte[]) data); } @@ -409,7 +396,6 @@ public class Binder { * Bind String data to a CLOB column. */ private void bindClob(DataBind dataBind, Object data) throws SQLException { - dataBind.setClob((String) data); } @@ -417,7 +403,6 @@ public class Binder { * Bind byte[] data to a BLOB column. */ private void bindBlob(DataBind dataBind, Object data) throws SQLException { - dataBind.setBlob((byte[]) data); } diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java index b429b4f58..0fffe3f12 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/DefaultTypeManager.java @@ -19,6 +19,7 @@ import io.ebean.types.Inet; import io.ebean.util.AnnotationUtil; import io.ebeaninternal.api.ExtraTypeFactory; import io.ebeaninternal.api.DbOffline; +import io.ebeaninternal.api.GeoTypeProvider; import io.ebeaninternal.server.core.bootup.BootupClasses; import io.ebeaninternal.server.deploy.meta.DeployBeanProperty; import io.ebeanservice.docstore.api.mapping.DocPropertyType; @@ -180,6 +181,7 @@ public final class DefaultTypeManager implements TypeManager { private final PlatformArrayTypeFactory arrayTypeListFactory; private final PlatformArrayTypeFactory arrayTypeSetFactory; + private GeoTypeBinder geoTypeBinder; /** * Create the DefaultTypeManager. @@ -211,6 +213,7 @@ public final class DefaultTypeManager implements TypeManager { initialiseJacksonTypes(config); loadTypesFromProviders(config, objectMapper); + loadGeoTypeBinder(config); if (bootupClasses != null) { initialiseCustomScalarTypes(bootupClasses); @@ -219,6 +222,13 @@ public final class DefaultTypeManager implements TypeManager { } } + private void loadGeoTypeBinder(DatabaseConfig config) { + final GeoTypeProvider provider = config.service(GeoTypeProvider.class); + if (provider != null) { + geoTypeBinder = provider.createBinder(config); + } + } + /** * Return the factory to use to support DB ARRAY types. */ @@ -348,6 +358,11 @@ public final class DefaultTypeManager implements TypeManager { return null; } + @Override + public GeoTypeBinder getGeoTypeBinder() { + return geoTypeBinder; + } + @Override public ScalarType getDbMapScalarType() { return (postgres) ? hstoreType : ScalarTypeJsonMap.typeFor(false, Types.VARCHAR); diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/GeoTypeBinder.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/GeoTypeBinder.java new file mode 100644 index 000000000..a8c8e338a --- /dev/null +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/GeoTypeBinder.java @@ -0,0 +1,14 @@ +package io.ebeaninternal.server.type; + +import java.sql.SQLException; + +/** + * Binder for Geometry types. + */ +public interface GeoTypeBinder { + + /** + * Bind the geometry type. + */ + void bind(DataBind b, int dataType, Object data) throws SQLException; +} diff --git a/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeManager.java b/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeManager.java index e4c038e79..7e2fa6d76 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeManager.java +++ b/ebean-core/src/main/java/io/ebeaninternal/server/type/TypeManager.java @@ -69,4 +69,9 @@ public interface TypeManager { * Return the ScalarType used to handle HSTORE (Map). */ ScalarType getDbMapScalarType(); + + /** + * Return the Geometry type binder if provided. + */ + GeoTypeBinder getGeoTypeBinder(); } diff --git a/ebean-postgis/pom.xml b/ebean-postgis/pom.xml index 40822a890..c0cd1b106 100644 --- a/ebean-postgis/pom.xml +++ b/ebean-postgis/pom.xml @@ -1,36 +1,40 @@ 4.0.0 - - io.ebean - ebean-postgis - 12.4.2-SNAPSHOT - - org.avaje - java8-oss - 2.2 + ebean-parent + io.ebean + 12.5.2-SNAPSHOT + ebean postgis + ebean postgis module + https://ebean.io/ + + ebean-postgis + 2.2.1 + 2.11.3 - - scm:git:git@github.com:ebean-orm/ebean-postgis.git - HEAD - - - + io.ebean - ebean - 12.4.1 + ebean-core + 12.5.2-SNAPSHOT provided + + com.fasterxml.jackson.core + jackson-core + ${jackson-core.version} + true + + net.postgis postgis-jdbc @@ -64,7 +68,7 @@ io.ebean ebean-test - 12.4.1 + 12.5.1 test diff --git a/ebean-postgis/src/main/java/io/ebean/postgis/RegisterFactory.java b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java similarity index 91% rename from ebean-postgis/src/main/java/io/ebean/postgis/RegisterFactory.java rename to ebean-postgis/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java index 8e1f3c5b8..a4990ad50 100644 --- a/ebean-postgis/src/main/java/io/ebean/postgis/RegisterFactory.java +++ b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisExtraTypeFactory.java @@ -13,12 +13,12 @@ import io.ebeaninternal.server.type.ScalarType; import java.util.ArrayList; import java.util.List; -public class RegisterFactory implements ExtraTypeFactory { +public class PostgisExtraTypeFactory implements ExtraTypeFactory { @Override public List> createTypes(DatabaseConfig config, Object objectMapper) { - List> list = new ArrayList>(); + List> list = new ArrayList<>(); list.add(new ScalarTypePgisPoint()); list.add(new ScalarTypePgisPolygon()); list.add(new ScalarTypePgisLineString()); diff --git a/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java new file mode 100644 index 000000000..7dd037e34 --- /dev/null +++ b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBindProvider.java @@ -0,0 +1,14 @@ +package io.ebean.postgis; + +import io.ebean.config.DatabaseConfig; +import io.ebeaninternal.api.GeoTypeProvider; +import io.ebeaninternal.server.type.GeoTypeBinder; + +public class PostgisGeoTypeBindProvider implements GeoTypeProvider { + + @Override + public GeoTypeBinder createBinder(DatabaseConfig config) { + boolean withGeolatte = config.getClassLoadConfig().isPresent("org.geolatte.geom.Geometry"); + return new PostgisGeoTypeBinder(withGeolatte); + } +} diff --git a/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBinder.java b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBinder.java new file mode 100644 index 000000000..368819892 --- /dev/null +++ b/ebean-postgis/src/main/java/io/ebean/postgis/PostgisGeoTypeBinder.java @@ -0,0 +1,32 @@ +package io.ebean.postgis; + +import io.ebeaninternal.server.type.DataBind; +import io.ebeaninternal.server.type.GeoTypeBinder; +import org.geolatte.geom.codec.Wkt; +import org.postgis.Geometry; +import org.postgis.PGgeometryLW; + +import java.sql.SQLException; + +class PostgisGeoTypeBinder implements GeoTypeBinder { + + private final boolean withGeolatte; + + PostgisGeoTypeBinder(boolean withGeolatte) { + this.withGeolatte = withGeolatte; + } + + @Override + public void bind(DataBind b, int dataType, Object data) throws SQLException { + if (data instanceof Geometry) { + b.setObject(new PGgeometryLW((Geometry) data)); + } else if (withGeolatte) { + b.setObject(new PGgeometryLW(toWktString(data))); + } + } + + private String toWktString(Object data) { + org.geolatte.geom.Geometry geoLatte = (org.geolatte.geom.Geometry)data; + return Wkt.newEncoder(Wkt.Dialect.POSTGIS_EWKT_1).encode(geoLatte); + } +} diff --git a/ebean-postgis/src/main/java/io/ebean/postgis/ScalarTypePgisBase.java b/ebean-postgis/src/main/java/io/ebean/postgis/ScalarTypePgisBase.java index 7f0e4e64a..8814bd280 100644 --- a/ebean-postgis/src/main/java/io/ebean/postgis/ScalarTypePgisBase.java +++ b/ebean-postgis/src/main/java/io/ebean/postgis/ScalarTypePgisBase.java @@ -1,11 +1,11 @@ package io.ebean.postgis; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; import io.ebeaninternal.server.type.DataBind; import io.ebeaninternal.server.type.DataReader; import io.ebeaninternal.server.type.ScalarType; import io.ebeanservice.docstore.api.mapping.DocPropertyType; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; import org.postgis.Geometry; import org.postgis.PGgeometry; import org.postgis.PGgeometryLW; @@ -13,7 +13,6 @@ import org.postgresql.util.PGobject; import java.io.DataInput; import java.io.DataOutput; -import java.io.IOException; import java.sql.SQLException; import java.sql.Types; @@ -77,12 +76,12 @@ abstract class ScalarTypePgisBase implements ScalarType { } @Override - public T readData(DataInput dataInput) throws IOException { + public T readData(DataInput dataInput) { return null; } @Override - public void writeData(DataOutput dataOutput, T v) throws IOException { + public void writeData(DataOutput dataOutput, T v) { } @@ -158,12 +157,12 @@ abstract class ScalarTypePgisBase implements ScalarType { @Override - public T jsonRead(JsonParser parser) throws IOException { + public T jsonRead(JsonParser parser) { return null; } @Override - public void jsonWrite(JsonGenerator writer, T value) throws IOException { + public void jsonWrite(JsonGenerator writer, T value) { } } diff --git a/ebean-postgis/src/main/java/io/ebean/postgis/latte/ScalarTypeGeoLatteBase.java b/ebean-postgis/src/main/java/io/ebean/postgis/latte/ScalarTypeGeoLatteBase.java index 4d5f8dbba..3abbc3fda 100644 --- a/ebean-postgis/src/main/java/io/ebean/postgis/latte/ScalarTypeGeoLatteBase.java +++ b/ebean-postgis/src/main/java/io/ebean/postgis/latte/ScalarTypeGeoLatteBase.java @@ -1,11 +1,11 @@ package io.ebean.postgis.latte; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; import io.ebeaninternal.server.type.DataBind; import io.ebeaninternal.server.type.DataReader; import io.ebeaninternal.server.type.ScalarType; import io.ebeanservice.docstore.api.mapping.DocPropertyType; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; import org.geolatte.geom.Geometry; import org.geolatte.geom.codec.Wkt; import org.postgis.PGgeometry; @@ -13,7 +13,6 @@ import org.postgis.PGgeometryLW; import java.io.DataInput; import java.io.DataOutput; -import java.io.IOException; import java.sql.SQLException; import java.sql.Types; @@ -71,12 +70,12 @@ abstract class ScalarTypeGeoLatteBase implements ScalarType< } @Override - public T readData(DataInput dataInput) throws IOException { + public T readData(DataInput dataInput) { return null; } @Override - public void writeData(DataOutput dataOutput, T v) throws IOException { + public void writeData(DataOutput dataOutput, T v) { } @@ -151,12 +150,12 @@ abstract class ScalarTypeGeoLatteBase implements ScalarType< } @Override - public T jsonRead(JsonParser parser) throws IOException { + public T jsonRead(JsonParser parser) { return null; } @Override - public void jsonWrite(JsonGenerator writer, T value) throws IOException { + public void jsonWrite(JsonGenerator writer, T value) { } } diff --git a/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.ExtraTypeFactory b/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.ExtraTypeFactory index 9ec14fff0..54cd37d74 100644 --- a/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.ExtraTypeFactory +++ b/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.ExtraTypeFactory @@ -1 +1 @@ -io.ebean.postgis.RegisterFactory \ No newline at end of file +io.ebean.postgis.PostgisExtraTypeFactory diff --git a/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.GeoTypeProvider b/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.GeoTypeProvider new file mode 100644 index 000000000..c69d76d20 --- /dev/null +++ b/ebean-postgis/src/main/resources/META-INF/services/io.ebeaninternal.api.GeoTypeProvider @@ -0,0 +1 @@ +io.ebean.postgis.PostgisGeoTypeBindProvider \ No newline at end of file diff --git a/ebean-postgis/src/test/java/org/example/domain/TestQuery.java b/ebean-postgis/src/test/java/org/example/domain/TestQuery.java index ae995d8c4..8fffb0047 100644 --- a/ebean-postgis/src/test/java/org/example/domain/TestQuery.java +++ b/ebean-postgis/src/test/java/org/example/domain/TestQuery.java @@ -1,9 +1,6 @@ package org.example.domain; -import static org.geolatte.geom.codec.Wkt.toWkt; -import static org.testng.Assert.assertNotNull; -import static org.testng.AssertJUnit.assertNull; - +import io.ebean.DB; import org.geolatte.geom.G2D; import org.geolatte.geom.LineString; import org.geolatte.geom.MultiLineString; @@ -17,7 +14,9 @@ import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; -import io.ebean.DB; +import static org.geolatte.geom.codec.Wkt.toWkt; +import static org.testng.Assert.assertNotNull; +import static org.testng.AssertJUnit.assertNull; public class TestQuery { @@ -110,18 +109,19 @@ public class TestQuery { // Approx 1100 meters away // 0.009999999999990905 degrees away -// System.err.println( -// DB -// .sqlQuery("SELECT st_distance(wgs84_point, ?), * FROM mybean").setParameter(toWkt(geolatteClosePoint)) -// .findOne() -// ); + System.err.println( + DB + .sqlQuery("SELECT st_distance(wgs84_point, ?), * FROM mybean") + .setParameter(toWkt(geolatteClosePoint)) + .findOne() + ); assertNotNull( DB .find(OtherBeanGeoLatte.class) .where() .raw("st_distance(wgs84Point, ?) < 0.011", toWkt(geolatteClosePoint)) -// .raw("st_distance(wgs84Point, ?) < 0.011 ", geolatteClosePoint) + .raw("st_distance(wgs84Point, ?) < 0.011 ", geolatteClosePoint) .findOne() ); @@ -130,7 +130,7 @@ public class TestQuery { .find(OtherBeanGeoLatte.class) .where() .raw("st_distance(wgs84Point, ?) < 0.009", toWkt(geolatteClosePoint)) -// .raw("st_distance(wgs84Point, ?) < 0.009", geolatteClosePoint) + .raw("st_distance(wgs84Point, ?) < 0.009", geolatteClosePoint) .findOne() ); @@ -139,7 +139,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("ST_Within(wgs84Point, ST_GeomFromText(?))", toWkt(enclosingPolygon)) -// .raw("ST_Within(wgs84Point, ?)", enclosingPolygon) + .raw("ST_Within(wgs84Point, ?)", enclosingPolygon) .findOne() ); @@ -147,7 +147,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("wgs84Point = ST_PointN(ST_GeomFromText(?), 2)", toWkt(lineString)) -// .raw("wgs84Point = ST_PointN(?, 2)", lineString) + .raw("wgs84Point = ST_PointN(?, 2)", lineString) .findOne() ); @@ -155,7 +155,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(ST_GeomFromText(?)), 2)", toWkt(multiPoint)) -// .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", multiPoint) + .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", multiPoint) .findOne() ); @@ -163,7 +163,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("ST_Within(wgs84Point, ST_GeomFromText(?))", toWkt(multiPolygon)) -// .raw("ST_Within(wgs84Point, ?)", multiPolygon) + .raw("ST_Within(wgs84Point, ?)", multiPolygon) .findOne() ); @@ -171,7 +171,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("ST_Intersects(wgs84Point, ST_GeomFromText(?))", toWkt(multiLineString)) -// .raw("ST_Intersects(wgs84Point, ?)", multiLineString) + .raw("ST_Intersects(wgs84Point, ?)", multiLineString) .findOne() ); } @@ -184,7 +184,7 @@ public class TestQuery { .find(MyBean.class) .where() .raw("st_distance(wgs84Point, ?) < 0.011", toWkt(geolatteClosePoint)) -// .raw("st_distance(wgs84Point, ?) < 0.011", new org.postgis.Point(toWkt(geolatteClosePoint))) + .raw("st_distance(wgs84Point, ?) < 0.011", new org.postgis.Point(toWkt(geolatteClosePoint))) .findOne() ); @@ -193,7 +193,7 @@ public class TestQuery { .find(MyBean.class) .where() .raw("st_distance(wgs84Point, ?) < 0.009", toWkt(geolatteClosePoint)) -// .raw("st_distance(wgs84Point, ?) < 0.009", postgisClosePoint) + .raw("st_distance(wgs84Point, ?) < 0.009", new org.postgis.Point(toWkt(geolatteClosePoint))) .findOne() ); @@ -202,7 +202,7 @@ public class TestQuery { .find(MyBean.class) .where() .raw("ST_Within(wgs84Point, ST_GeomFromText(?))", toWkt(enclosingPolygon)) -// .raw("ST_Within(wgs84Point, ?)", new org.postgis.Polygon(toWkt(enclosingPolygon))) + .raw("ST_Within(wgs84Point, ?)", new org.postgis.Polygon(toWkt(enclosingPolygon))) .findOne() ); @@ -210,7 +210,7 @@ public class TestQuery { DB.find(MyBean.class) .where() .raw("wgs84Point = ST_PointN(ST_GeomFromText(?), 2)", toWkt(lineString)) -// .raw("wgs84Point = ST_PointN(?, 2)", new org.postgis.LineString(toWkt(lineString))) + .raw("wgs84Point = ST_PointN(?, 2)", new org.postgis.LineString(toWkt(lineString))) .findOne() ); @@ -218,7 +218,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(ST_GeomFromText(?)), 2)", toWkt(multiPoint)) -// .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", new org.postgis.MultiPoint(toWkt(multiPoint))) + .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", new org.postgis.MultiPoint(toWkt(multiPoint))) .findOne() ); @@ -226,7 +226,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(ST_GeomFromText(?)), 2)", toWkt(multiPoint)) -// .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", new org.postgis.MultiPoint(toWkt(multiPoint))) + .raw("wgs84Point = ST_PointN(ST_LineFromMultiPoint(?), 2)", new org.postgis.MultiPoint(toWkt(multiPoint))) .findOne() ); @@ -235,7 +235,7 @@ public class TestQuery { .find(MyBean.class) .where() .raw("ST_Within(wgs84Point, ST_GeomFromText(?))", toWkt(multiPolygon)) -// .raw("ST_Within(wgs84Point, ?)", new org.postgis.Polygon(toWkt(multiPolygon))) + .raw("ST_Within(wgs84Point, ?)", new org.postgis.MultiPolygon(toWkt(multiPolygon))) .findOne() ); @@ -243,7 +243,7 @@ public class TestQuery { DB.find(OtherBeanGeoLatte.class) .where() .raw("ST_Intersects(wgs84Point, ST_GeomFromText(?))", toWkt(multiLineString)) -// .raw("ST_Intersects(wgs84Point, ?)", new org.postgis.MultiLineString(toWkt(multiLineString))) + .raw("ST_Intersects(wgs84Point, ?)", new org.postgis.MultiLineString(toWkt(multiLineString))) .findOne() ); } diff --git a/pom.xml b/pom.xml index f5d19839d..7fab8344c 100644 --- a/pom.xml +++ b/pom.xml @@ -75,6 +75,7 @@ querybean-generator kotlin-querybean-generator ebean-querybean + ebean-postgis