diff --git a/hibernate-spatial/databases/postgispg95/resources/hibernate.properties b/hibernate-spatial/databases/postgispg95/resources/hibernate.properties index 3b19dc1a719b..d35e2cf8fc76 100644 --- a/hibernate-spatial/databases/postgispg95/resources/hibernate.properties +++ b/hibernate-spatial/databases/postgispg95/resources/hibernate.properties @@ -8,7 +8,7 @@ hibernate.test.new_metadata_mappings = true hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect hibernate.connection.driver_class org.postgresql.Driver -hibernate.connection.url jdbc:postgresql://hibpg95.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:5432/hibernate +hibernate.connection.url jdbc:postgresql://hbpg96.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:5432/hibernate hibernate.connection.username hibbrtru hibernate.connection.password QilTygcxHwk1 diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialFunctions.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialFunctions.java index d4d4aa283a34..e51df68ee88c 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialFunctions.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialFunctions.java @@ -62,7 +62,7 @@ public void dimension(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getDimension(); - String hql = format( "SELECT id, dimension(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, dimension(geom) FROM %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -81,7 +81,7 @@ public void astext(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getAsText(); - String hql = format( "SELECT id, astext(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, astext(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -101,7 +101,7 @@ public void asbinary(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getAsBinary(); - String hql = format( "SELECT id, asbinary(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, asbinary(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -121,10 +121,10 @@ public void geometrytype(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getGeometryType(); String hql = format( - "SELECT id, geometrytype(geom) from org.hibernate.spatial.integration.%s.GeomEntity", - pckg + "SELECT id, geometrytype(geom) from %s", + entityName( pckg ) ); - retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); + retrieveHQLResultsAndCompare( dbexpected, hql, entityName( pckg ) ); } @Test @@ -142,7 +142,7 @@ public void srid(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getSrid(); - String hql = format( "SELECT id, srid(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, srid(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -161,7 +161,7 @@ public void issimple(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getIsSimple(); - String hql = format( "SELECT id, issimple(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, issimple(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -180,7 +180,7 @@ public void isempty(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getIsEmpty(); - String hql = format( "SELECT id, isEmpty(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, isEmpty(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -199,7 +199,7 @@ public void boundary(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getBoundary(); - String hql = format( "SELECT id, boundary(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, boundary(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -218,7 +218,7 @@ public void envelope(String pckg) throws SQLException { return; } Map dbexpected = expectationsFactory.getEnvelope(); - String hql = format( "SELECT id, envelope(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = format( "SELECT id, envelope(geom) from %s", entityName( pckg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, pckg ); } @@ -238,9 +238,9 @@ public void within(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getWithin( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, within(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, within(geom, :filter) from %s " + "where within(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -263,9 +263,9 @@ public void equals(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getEquals( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, equals(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, equals(geom, :filter) from %s " + "where equals(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -288,9 +288,9 @@ public void crosses(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getCrosses( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, crosses(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, crosses(geom, :filter) from %s " + "where crosses(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -314,9 +314,9 @@ public void contains(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getContains( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, contains(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, contains(geom, :filter) from %s " + "where contains(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -339,9 +339,9 @@ public void disjoint(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getDisjoint( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, disjoint(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, disjoint(geom, :filter) from %s " + "where disjoint(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -364,9 +364,9 @@ public void intersects(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getIntersects( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, intersects(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, intersects(geom, :filter) from %s " + "where intersects(geom, :filter) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -389,9 +389,8 @@ public void overlaps(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getOverlaps( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, overlaps(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where overlaps(geom, :filter) = true and srid(geom) = %d", - pckg, + "SELECT id, overlaps(geom, :filter) from %s where overlaps(geom, :filter) = true and srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -413,9 +412,8 @@ public void touches(String pckg) throws SQLException { return; } String hql = format( - "SELECT id, touches(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where touches(geom, :filter) = true and srid(geom) = %d", - pckg, + "SELECT id, touches(geom, :filter) from %s where touches(geom, :filter) = true and srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map dbexpected = expectationsFactory.getTouches( expectationsFactory.getTestPolygon() ); @@ -443,9 +441,9 @@ public void relate(String pckg) throws SQLException { matrix ); String hql = format( - "SELECT id, relate(geom, :filter, :matrix) from org.hibernate.spatial.integration.%s.GeomEntity " + + "SELECT id, relate(geom, :filter, :matrix) from %s " + "where relate(geom, :filter, :matrix) = true and srid(geom) = %d", - pckg, + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); @@ -475,8 +473,7 @@ public void distance(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getDistance( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, distance(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, distance(geom, :filter) from %s where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPolygon() ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -498,8 +495,8 @@ public void buffer(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getBuffer( Double.valueOf( 1.0 ) ); String hql = format( - "SELECT id, buffer(geom, :distance) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, buffer(geom, :distance) from %s where srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "distance", Double.valueOf( 1.0 ) ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -528,8 +525,8 @@ public void convexhull(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getConvexHull( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, convexhull(geomunion(geom, :polygon)) from org.hibernate.spatial.integration" + - ".%s.GeomEntity where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, convexhull(geomunion(geom, :polygon)) from %s where srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -556,8 +553,8 @@ public void intersection(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getIntersection( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, intersection(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, intersection(geom, :polygon) from %s where srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -579,8 +576,8 @@ public void difference(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getDifference( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, difference(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, difference(geom, :polygon) from %s where srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -602,9 +599,8 @@ public void symdifference(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getSymDifference( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, symdifference(geom, :polygon) from " + - "org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d", - pckg, + "SELECT id, symdifference(geom, :polygon) from %s where srid(geom) = %d", + entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() ); @@ -627,8 +623,8 @@ public void geomunion(String pckg) throws SQLException { } Map dbexpected = expectationsFactory.getGeomUnion( expectationsFactory.getTestPolygon() ); String hql = format( - "SELECT id, geomunion(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, geomunion(geom, :polygon) from %s " + + "where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -655,8 +651,8 @@ public void dwithin(String pckg) throws SQLException { ); String hql = format( "SELECT id, dwithin(geom, :filter, :distance) from " + - "org.hibernate.spatial.integration.%s.GeomEntity where dwithin(geom, :filter, :distance) = true " + - "and srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "%s where dwithin(geom, :filter, :distance) = true " + + "and srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "filter", expectationsFactory.getTestPoint() ); if ( getDialect() instanceof OracleSpatial10gDialect ) { @@ -693,8 +689,8 @@ public void transform(String pckg) throws SQLException { int epsg = 4324; Map dbexpected = expectationsFactory.getTransform( epsg ); String hql = format( - "SELECT id, transform(geom, :epsg) from org.hibernate.spatial.integration.%s.GeomEntity " + - "where srid(geom) = %d", pckg, expectationsFactory.getTestSrid() + "SELECT id, transform(geom, :epsg) from %s " + + "where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid() ); Map params = createQueryParams( "epsg", Integer.valueOf( epsg ) ); retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg ); @@ -717,7 +713,7 @@ public void extent(String pckg) throws SQLException { } // here we just check if we get a result, and can read it String hql = format( - "SELECT id, extent(geom) from org.hibernate.spatial.integration.%s.GeomEntity group by id", pckg + "SELECT id, extent(geom) from %s group by id", entityName( pckg ) ); Map hsreceived = new HashMap(); doInSession( hql, hsreceived, new HashMap() ); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java index 98a4bb1ad7db..c82c16a650ff 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java @@ -19,7 +19,7 @@ import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.criterion.SpatialRestrictions; import org.hibernate.spatial.dialect.hana.HANASpatialDialect; -import org.hibernate.spatial.integration.jts.GeomEntity; +import org.hibernate.spatial.integration.jts.JtsGeomEntity; import org.hibernate.spatial.testing.SpatialDialectMatcher; import org.hibernate.spatial.testing.SpatialFunctionalTestCase; @@ -188,7 +188,7 @@ private void retrieveAndCompare(Map dbexpected, Criterion spat try { session = openSession(); tx = session.beginTransaction(); - Criteria criteria = session.createCriteria( GeomEntity.class ); + Criteria criteria = session.createCriteria( JtsGeomEntity.class ); criteria.add( spatialCriterion ); compare( dbexpected, criteria.list() ); } @@ -207,7 +207,7 @@ private void compare(Map dbexpected, List list) { for ( Map.Entry entry : dbexpected.entrySet() ) { if ( entry.getValue() ) { cnt++; - if ( !findInList( entry.getKey(), (List) list ) ) { + if ( !findInList( entry.getKey(), (List) list ) ) { fail( String.format( "Expected object with id= %d, but not found in result", entry.getKey() ) ); } } @@ -216,8 +216,8 @@ private void compare(Map dbexpected, List list) { LOG.info( String.format( "Found %d objects within testsuite-suite polygon.", cnt ) ); } - private boolean findInList(Integer id, List list) { - for ( GeomEntity entity : list ) { + private boolean findInList(Integer id, List list) { + for ( JtsGeomEntity entity : list ) { if ( entity.getId().equals( id ) ) { return true; } diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/GeomEntity.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/JtsGeomEntity.java similarity index 86% rename from hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/GeomEntity.java rename to hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/JtsGeomEntity.java index a1567db92878..5e25e1a459d3 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/GeomEntity.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/JtsGeomEntity.java @@ -27,7 +27,7 @@ */ @Entity @Table(name = "geomtest") -public class GeomEntity implements GeomEntityLike { +public class JtsGeomEntity implements GeomEntityLike { @Id @@ -37,10 +37,10 @@ public class GeomEntity implements GeomEntityLike { private Geometry geom; - public static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException { + public static JtsGeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException { WktDecoder decoder = getWktDecoder( dialect ); Geometry geom = JTS.to( decoder.decode( element.wkt ) ); - GeomEntity result = new GeomEntity(); + JtsGeomEntity result = new JtsGeomEntity(); result.setId( element.id ); result.setGeom( geom ); result.setType( element.type ); @@ -80,7 +80,7 @@ public boolean equals(Object o) { return false; } - GeomEntity geomEntity = (GeomEntity) o; + JtsGeomEntity geomEntity = (JtsGeomEntity) o; if ( !id.equals( geomEntity.id ) ) { return false; diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/TestStoreRetrieveUsingJTS.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/TestStoreRetrieveUsingJTS.java index cbacfc45cc9e..48e3abd259bc 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/TestStoreRetrieveUsingJTS.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/TestStoreRetrieveUsingJTS.java @@ -26,7 +26,7 @@ * are equal to the Geometrys stored. */ @Skip(condition = SpatialDialectMatcher.class, message = "No Spatial Dialect") -public class TestStoreRetrieveUsingJTS extends AbstractTestStoreRetrieve { +public class TestStoreRetrieveUsingJTS extends AbstractTestStoreRetrieve { private static final HSMessageLogger LOG = Logger.getMessageLogger( HSMessageLogger.class, @@ -45,15 +45,15 @@ protected GeometryEquality getGeometryEquality() { } @Override - protected Class getGeomEntityClass() { - return GeomEntity.class; + protected Class getGeomEntityClass() { + return JtsGeomEntity.class; } @Override - protected GeomEntity createFrom( + protected JtsGeomEntity createFrom( TestDataElement element, Dialect dialect) { try { - return GeomEntity.createFrom( element, dialect ); + return JtsGeomEntity.createFrom( element, dialect ); } catch (ParseException e) { throw new RuntimeException( e ); diff --git a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/SpatialFunctionalTestCase.java b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/SpatialFunctionalTestCase.java index 8453e64b370f..48a4a9751c6c 100644 --- a/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/SpatialFunctionalTestCase.java +++ b/hibernate-spatial/src/test/java/org/hibernate/spatial/testing/SpatialFunctionalTestCase.java @@ -20,6 +20,7 @@ import org.hibernate.spatial.HSMessageLogger; import org.hibernate.spatial.SpatialDialect; import org.hibernate.spatial.SpatialFunction; +import org.hibernate.spatial.integration.jts.JtsGeomEntity; import org.hibernate.testing.AfterClassOnce; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -74,7 +75,7 @@ private void cleanUpTest(String pckg) { try { session = openSession(); tx = session.beginTransaction(); - String hql = String.format( "delete from org.hibernate.spatial.integration.%s.GeomEntity", pckg ); + String hql = String.format( "delete from %s", entityName(pckg) ); Query q = session.createQuery( hql ); q.executeUpdate(); tx.commit(); @@ -146,7 +147,7 @@ public String[] getMappings() { protected Class[] getAnnotatedClasses() { return new Class[] { org.hibernate.spatial.integration.geolatte.GeomEntity.class, - org.hibernate.spatial.integration.jts.GeomEntity.class + JtsGeomEntity.class }; } @@ -253,4 +254,12 @@ else if ( expected instanceof Geometry ) { } } + protected String entityName(String pckg) { + if (JTS.equalsIgnoreCase( pckg )) { + return "org.hibernate.spatial.integration.jts.JtsGeomEntity"; + } else { + return "org.hibernate.spatial.integration.geolatte.GeomEntity"; + } + } + }