Search code examples
hibernatepostgishibernate-spatial

Hibernate SpatialRestrictions & PostGIS alias: 'column does not exist'


When I specify a Criterion from SpatialRestrictions (e.g. SpatialRestrictions.intersects(propertyName, geometryObj)) the generated SQL is invalid as the column name has been aliased and used incorrectly:

Generated SQL

SELECT this_.GEO_LOCATION as y10_ FROM schema.GEO this_ WHERE ( ST_intersects(y10_, 'SRID=4326;POLYGON(...)') OR ST_intersects(y10_, 'SRID=4326;POLYGON(...)'))

Is there a way to force the projection alias to be ignored and just use table_alias.column?


Solution

  • I solved this by passing "this." + propertyName to the SpatialRestriction.