Skip to content

Commit d9dd1eb

Browse files
committed
HHH-13083 - Fix matrix tests
1 parent 89e36cf commit d9dd1eb

File tree

6 files changed

+73
-68
lines changed

6 files changed

+73
-68
lines changed

hibernate-spatial/databases/postgispg95/resources/hibernate.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
hibernate.test.new_metadata_mappings = true
99
hibernate.dialect org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect
1010
hibernate.connection.driver_class org.postgresql.Driver
11-
hibernate.connection.url jdbc:postgresql://hibpg95.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:5432/hibernate
11+
hibernate.connection.url jdbc:postgresql://hbpg96.cctaez8ywvn2.eu-west-1.rds.amazonaws.com:5432/hibernate
1212
hibernate.connection.username hibbrtru
1313
hibernate.connection.password QilTygcxHwk1
1414

hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialFunctions.java

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void dimension(String pckg) throws SQLException {
6262
return;
6363
}
6464
Map<Integer, Integer> dbexpected = expectationsFactory.getDimension();
65-
String hql = format( "SELECT id, dimension(geom) FROM org.hibernate.spatial.integration.%s.GeomEntity", pckg );
65+
String hql = format( "SELECT id, dimension(geom) FROM %s", entityName( pckg ) );
6666
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
6767
}
6868

@@ -81,7 +81,7 @@ public void astext(String pckg) throws SQLException {
8181
return;
8282
}
8383
Map<Integer, String> dbexpected = expectationsFactory.getAsText();
84-
String hql = format( "SELECT id, astext(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
84+
String hql = format( "SELECT id, astext(geom) from %s", entityName( pckg ) );
8585
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
8686
}
8787

@@ -101,7 +101,7 @@ public void asbinary(String pckg) throws SQLException {
101101
return;
102102
}
103103
Map<Integer, byte[]> dbexpected = expectationsFactory.getAsBinary();
104-
String hql = format( "SELECT id, asbinary(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
104+
String hql = format( "SELECT id, asbinary(geom) from %s", entityName( pckg ) );
105105
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
106106
}
107107

@@ -121,10 +121,10 @@ public void geometrytype(String pckg) throws SQLException {
121121
}
122122
Map<Integer, String> dbexpected = expectationsFactory.getGeometryType();
123123
String hql = format(
124-
"SELECT id, geometrytype(geom) from org.hibernate.spatial.integration.%s.GeomEntity",
125-
pckg
124+
"SELECT id, geometrytype(geom) from %s",
125+
entityName( pckg )
126126
);
127-
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
127+
retrieveHQLResultsAndCompare( dbexpected, hql, entityName( pckg ) );
128128
}
129129

130130
@Test
@@ -142,7 +142,7 @@ public void srid(String pckg) throws SQLException {
142142
return;
143143
}
144144
Map<Integer, Integer> dbexpected = expectationsFactory.getSrid();
145-
String hql = format( "SELECT id, srid(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
145+
String hql = format( "SELECT id, srid(geom) from %s", entityName( pckg ) );
146146
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
147147
}
148148

@@ -161,7 +161,7 @@ public void issimple(String pckg) throws SQLException {
161161
return;
162162
}
163163
Map<Integer, Boolean> dbexpected = expectationsFactory.getIsSimple();
164-
String hql = format( "SELECT id, issimple(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
164+
String hql = format( "SELECT id, issimple(geom) from %s", entityName( pckg ) );
165165
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
166166
}
167167

@@ -180,7 +180,7 @@ public void isempty(String pckg) throws SQLException {
180180
return;
181181
}
182182
Map<Integer, Boolean> dbexpected = expectationsFactory.getIsEmpty();
183-
String hql = format( "SELECT id, isEmpty(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
183+
String hql = format( "SELECT id, isEmpty(geom) from %s", entityName( pckg ) );
184184
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
185185
}
186186

@@ -199,7 +199,7 @@ public void boundary(String pckg) throws SQLException {
199199
return;
200200
}
201201
Map<Integer, Geometry> dbexpected = expectationsFactory.getBoundary();
202-
String hql = format( "SELECT id, boundary(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
202+
String hql = format( "SELECT id, boundary(geom) from %s", entityName( pckg ) );
203203
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
204204
}
205205

@@ -218,7 +218,7 @@ public void envelope(String pckg) throws SQLException {
218218
return;
219219
}
220220
Map<Integer, Geometry> dbexpected = expectationsFactory.getEnvelope();
221-
String hql = format( "SELECT id, envelope(geom) from org.hibernate.spatial.integration.%s.GeomEntity", pckg );
221+
String hql = format( "SELECT id, envelope(geom) from %s", entityName( pckg ) );
222222
retrieveHQLResultsAndCompare( dbexpected, hql, pckg );
223223
}
224224

@@ -238,9 +238,9 @@ public void within(String pckg) throws SQLException {
238238
}
239239
Map<Integer, Boolean> dbexpected = expectationsFactory.getWithin( expectationsFactory.getTestPolygon() );
240240
String hql = format(
241-
"SELECT id, within(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
241+
"SELECT id, within(geom, :filter) from %s " +
242242
"where within(geom, :filter) = true and srid(geom) = %d",
243-
pckg,
243+
entityName( pckg ),
244244
expectationsFactory.getTestSrid()
245245
);
246246
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -263,9 +263,9 @@ public void equals(String pckg) throws SQLException {
263263
}
264264
Map<Integer, Boolean> dbexpected = expectationsFactory.getEquals( expectationsFactory.getTestPolygon() );
265265
String hql = format(
266-
"SELECT id, equals(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
266+
"SELECT id, equals(geom, :filter) from %s " +
267267
"where equals(geom, :filter) = true and srid(geom) = %d",
268-
pckg,
268+
entityName( pckg ),
269269
expectationsFactory.getTestSrid()
270270
);
271271
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -288,9 +288,9 @@ public void crosses(String pckg) throws SQLException {
288288
}
289289
Map<Integer, Boolean> dbexpected = expectationsFactory.getCrosses( expectationsFactory.getTestPolygon() );
290290
String hql = format(
291-
"SELECT id, crosses(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
291+
"SELECT id, crosses(geom, :filter) from %s " +
292292
"where crosses(geom, :filter) = true and srid(geom) = %d",
293-
pckg,
293+
entityName( pckg ),
294294
expectationsFactory.getTestSrid()
295295
);
296296
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -314,9 +314,9 @@ public void contains(String pckg) throws SQLException {
314314
}
315315
Map<Integer, Boolean> dbexpected = expectationsFactory.getContains( expectationsFactory.getTestPolygon() );
316316
String hql = format(
317-
"SELECT id, contains(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
317+
"SELECT id, contains(geom, :filter) from %s " +
318318
"where contains(geom, :filter) = true and srid(geom) = %d",
319-
pckg,
319+
entityName( pckg ),
320320
expectationsFactory.getTestSrid()
321321
);
322322
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -339,9 +339,9 @@ public void disjoint(String pckg) throws SQLException {
339339
}
340340
Map<Integer, Boolean> dbexpected = expectationsFactory.getDisjoint( expectationsFactory.getTestPolygon() );
341341
String hql = format(
342-
"SELECT id, disjoint(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
342+
"SELECT id, disjoint(geom, :filter) from %s " +
343343
"where disjoint(geom, :filter) = true and srid(geom) = %d",
344-
pckg,
344+
entityName( pckg ),
345345
expectationsFactory.getTestSrid()
346346
);
347347
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -364,9 +364,9 @@ public void intersects(String pckg) throws SQLException {
364364
}
365365
Map<Integer, Boolean> dbexpected = expectationsFactory.getIntersects( expectationsFactory.getTestPolygon() );
366366
String hql = format(
367-
"SELECT id, intersects(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
367+
"SELECT id, intersects(geom, :filter) from %s " +
368368
"where intersects(geom, :filter) = true and srid(geom) = %d",
369-
pckg,
369+
entityName( pckg ),
370370
expectationsFactory.getTestSrid()
371371
);
372372
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -389,9 +389,8 @@ public void overlaps(String pckg) throws SQLException {
389389
}
390390
Map<Integer, Boolean> dbexpected = expectationsFactory.getOverlaps( expectationsFactory.getTestPolygon() );
391391
String hql = format(
392-
"SELECT id, overlaps(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
393-
"where overlaps(geom, :filter) = true and srid(geom) = %d",
394-
pckg,
392+
"SELECT id, overlaps(geom, :filter) from %s where overlaps(geom, :filter) = true and srid(geom) = %d",
393+
entityName( pckg ),
395394
expectationsFactory.getTestSrid()
396395
);
397396
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -413,9 +412,8 @@ public void touches(String pckg) throws SQLException {
413412
return;
414413
}
415414
String hql = format(
416-
"SELECT id, touches(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
417-
"where touches(geom, :filter) = true and srid(geom) = %d",
418-
pckg,
415+
"SELECT id, touches(geom, :filter) from %s where touches(geom, :filter) = true and srid(geom) = %d",
416+
entityName( pckg ),
419417
expectationsFactory.getTestSrid()
420418
);
421419
Map<Integer, Boolean> dbexpected = expectationsFactory.getTouches( expectationsFactory.getTestPolygon() );
@@ -443,9 +441,9 @@ public void relate(String pckg) throws SQLException {
443441
matrix
444442
);
445443
String hql = format(
446-
"SELECT id, relate(geom, :filter, :matrix) from org.hibernate.spatial.integration.%s.GeomEntity " +
444+
"SELECT id, relate(geom, :filter, :matrix) from %s " +
447445
"where relate(geom, :filter, :matrix) = true and srid(geom) = %d",
448-
pckg,
446+
entityName( pckg ),
449447
expectationsFactory.getTestSrid()
450448
);
451449
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
@@ -475,8 +473,7 @@ public void distance(String pckg) throws SQLException {
475473
}
476474
Map<Integer, Double> dbexpected = expectationsFactory.getDistance( expectationsFactory.getTestPolygon() );
477475
String hql = format(
478-
"SELECT id, distance(geom, :filter) from org.hibernate.spatial.integration.%s.GeomEntity " +
479-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
476+
"SELECT id, distance(geom, :filter) from %s where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid()
480477
);
481478
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPolygon() );
482479
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -498,8 +495,8 @@ public void buffer(String pckg) throws SQLException {
498495
}
499496
Map<Integer, Geometry> dbexpected = expectationsFactory.getBuffer( Double.valueOf( 1.0 ) );
500497
String hql = format(
501-
"SELECT id, buffer(geom, :distance) from org.hibernate.spatial.integration.%s.GeomEntity " +
502-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
498+
"SELECT id, buffer(geom, :distance) from %s where srid(geom) = %d",
499+
entityName( pckg ), expectationsFactory.getTestSrid()
503500
);
504501
Map<String, Object> params = createQueryParams( "distance", Double.valueOf( 1.0 ) );
505502
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -528,8 +525,8 @@ public void convexhull(String pckg) throws SQLException {
528525
}
529526
Map<Integer, Geometry> dbexpected = expectationsFactory.getConvexHull( expectationsFactory.getTestPolygon() );
530527
String hql = format(
531-
"SELECT id, convexhull(geomunion(geom, :polygon)) from org.hibernate.spatial.integration" +
532-
".%s.GeomEntity where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
528+
"SELECT id, convexhull(geomunion(geom, :polygon)) from %s where srid(geom) = %d",
529+
entityName( pckg ), expectationsFactory.getTestSrid()
533530
);
534531
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
535532
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -556,8 +553,8 @@ public void intersection(String pckg) throws SQLException {
556553
}
557554
Map<Integer, Geometry> dbexpected = expectationsFactory.getIntersection( expectationsFactory.getTestPolygon() );
558555
String hql = format(
559-
"SELECT id, intersection(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " +
560-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
556+
"SELECT id, intersection(geom, :polygon) from %s where srid(geom) = %d",
557+
entityName( pckg ), expectationsFactory.getTestSrid()
561558
);
562559
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
563560
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -579,8 +576,8 @@ public void difference(String pckg) throws SQLException {
579576
}
580577
Map<Integer, Geometry> dbexpected = expectationsFactory.getDifference( expectationsFactory.getTestPolygon() );
581578
String hql = format(
582-
"SELECT id, difference(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " +
583-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
579+
"SELECT id, difference(geom, :polygon) from %s where srid(geom) = %d",
580+
entityName( pckg ), expectationsFactory.getTestSrid()
584581
);
585582
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
586583
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -602,9 +599,8 @@ public void symdifference(String pckg) throws SQLException {
602599
}
603600
Map<Integer, Geometry> dbexpected = expectationsFactory.getSymDifference( expectationsFactory.getTestPolygon() );
604601
String hql = format(
605-
"SELECT id, symdifference(geom, :polygon) from " +
606-
"org.hibernate.spatial.integration.%s.GeomEntity where srid(geom) = %d",
607-
pckg,
602+
"SELECT id, symdifference(geom, :polygon) from %s where srid(geom) = %d",
603+
entityName( pckg ),
608604
expectationsFactory.getTestSrid()
609605
);
610606
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
@@ -627,8 +623,8 @@ public void geomunion(String pckg) throws SQLException {
627623
}
628624
Map<Integer, Geometry> dbexpected = expectationsFactory.getGeomUnion( expectationsFactory.getTestPolygon() );
629625
String hql = format(
630-
"SELECT id, geomunion(geom, :polygon) from org.hibernate.spatial.integration.%s.GeomEntity " +
631-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
626+
"SELECT id, geomunion(geom, :polygon) from %s " +
627+
"where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid()
632628
);
633629
Map<String, Object> params = createQueryParams( "polygon", expectationsFactory.getTestPolygon() );
634630
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -655,8 +651,8 @@ public void dwithin(String pckg) throws SQLException {
655651
);
656652
String hql = format(
657653
"SELECT id, dwithin(geom, :filter, :distance) from " +
658-
"org.hibernate.spatial.integration.%s.GeomEntity where dwithin(geom, :filter, :distance) = true " +
659-
"and srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
654+
"%s where dwithin(geom, :filter, :distance) = true " +
655+
"and srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid()
660656
);
661657
Map<String, Object> params = createQueryParams( "filter", expectationsFactory.getTestPoint() );
662658
if ( getDialect() instanceof OracleSpatial10gDialect ) {
@@ -693,8 +689,8 @@ public void transform(String pckg) throws SQLException {
693689
int epsg = 4324;
694690
Map<Integer, Geometry> dbexpected = expectationsFactory.getTransform( epsg );
695691
String hql = format(
696-
"SELECT id, transform(geom, :epsg) from org.hibernate.spatial.integration.%s.GeomEntity " +
697-
"where srid(geom) = %d", pckg, expectationsFactory.getTestSrid()
692+
"SELECT id, transform(geom, :epsg) from %s " +
693+
"where srid(geom) = %d", entityName( pckg ), expectationsFactory.getTestSrid()
698694
);
699695
Map<String, Object> params = createQueryParams( "epsg", Integer.valueOf( epsg ) );
700696
retrieveHQLResultsAndCompare( dbexpected, hql, params, pckg );
@@ -717,7 +713,7 @@ public void extent(String pckg) throws SQLException {
717713
}
718714
// here we just check if we get a result, and can read it
719715
String hql = format(
720-
"SELECT id, extent(geom) from org.hibernate.spatial.integration.%s.GeomEntity group by id", pckg
716+
"SELECT id, extent(geom) from %s group by id", entityName( pckg )
721717
);
722718
Map<Integer, Object> hsreceived = new HashMap<Integer, Object>();
723719
doInSession( hql, hsreceived, new HashMap<String, Object>() );

hibernate-spatial/src/test/java/org/hibernate/spatial/integration/TestSpatialRestrictions.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.hibernate.spatial.SpatialFunction;
2020
import org.hibernate.spatial.criterion.SpatialRestrictions;
2121
import org.hibernate.spatial.dialect.hana.HANASpatialDialect;
22-
import org.hibernate.spatial.integration.jts.GeomEntity;
22+
import org.hibernate.spatial.integration.jts.JtsGeomEntity;
2323
import org.hibernate.spatial.testing.SpatialDialectMatcher;
2424
import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
2525

@@ -188,7 +188,7 @@ private void retrieveAndCompare(Map<Integer, Boolean> dbexpected, Criterion spat
188188
try {
189189
session = openSession();
190190
tx = session.beginTransaction();
191-
Criteria criteria = session.createCriteria( GeomEntity.class );
191+
Criteria criteria = session.createCriteria( JtsGeomEntity.class );
192192
criteria.add( spatialCriterion );
193193
compare( dbexpected, criteria.list() );
194194
}
@@ -207,7 +207,7 @@ private void compare(Map<Integer, Boolean> dbexpected, List list) {
207207
for ( Map.Entry<Integer, Boolean> entry : dbexpected.entrySet() ) {
208208
if ( entry.getValue() ) {
209209
cnt++;
210-
if ( !findInList( entry.getKey(), (List<GeomEntity>) list ) ) {
210+
if ( !findInList( entry.getKey(), (List<JtsGeomEntity>) list ) ) {
211211
fail( String.format( "Expected object with id= %d, but not found in result", entry.getKey() ) );
212212
}
213213
}
@@ -216,8 +216,8 @@ private void compare(Map<Integer, Boolean> dbexpected, List list) {
216216
LOG.info( String.format( "Found %d objects within testsuite-suite polygon.", cnt ) );
217217
}
218218

219-
private boolean findInList(Integer id, List<GeomEntity> list) {
220-
for ( GeomEntity entity : list ) {
219+
private boolean findInList(Integer id, List<JtsGeomEntity> list) {
220+
for ( JtsGeomEntity entity : list ) {
221221
if ( entity.getId().equals( id ) ) {
222222
return true;
223223
}

hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/GeomEntity.java renamed to hibernate-spatial/src/test/java/org/hibernate/spatial/integration/jts/JtsGeomEntity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
@Entity
2929
@Table(name = "geomtest")
30-
public class GeomEntity implements GeomEntityLike<Geometry> {
30+
public class JtsGeomEntity implements GeomEntityLike<Geometry> {
3131

3232

3333
@Id
@@ -37,10 +37,10 @@ public class GeomEntity implements GeomEntityLike<Geometry> {
3737

3838
private Geometry geom;
3939

40-
public static GeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException {
40+
public static JtsGeomEntity createFrom(TestDataElement element, Dialect dialect) throws ParseException {
4141
WktDecoder decoder = getWktDecoder( dialect );
4242
Geometry geom = JTS.to( decoder.decode( element.wkt ) );
43-
GeomEntity result = new GeomEntity();
43+
JtsGeomEntity result = new JtsGeomEntity();
4444
result.setId( element.id );
4545
result.setGeom( geom );
4646
result.setType( element.type );
@@ -80,7 +80,7 @@ public boolean equals(Object o) {
8080
return false;
8181
}
8282

83-
GeomEntity geomEntity = (GeomEntity) o;
83+
JtsGeomEntity geomEntity = (JtsGeomEntity) o;
8484

8585
if ( !id.equals( geomEntity.id ) ) {
8686
return false;

0 commit comments

Comments
 (0)