I'm trying to query spatial relations between my entities but keep getting this exception:
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: ( near line 1,
My entities are working properly, so is the mapping. I believe that my query has the issue:
SELECT r FROM Regiao r, Imovel i WHERE r.nivel = :nivel AND contains(r.regiao, i.latlng)
Where both r.regiao and i.latln are GeometryType mapped (one being a Polygon and the other one a Point.
Ps.: As I asked the question I finally understood the issue.
Apparently the syntax of spatial functions requires you to test it against boolean values so I had to add the comparison in the end of my query:
SELECT r FROM Regiao r, Imovel i WHERE r.nivel = :nivel AND contains(r.regiao, i.latlng) = TRUE
For me this didn't seem to solve a similar problem. I reverted to using Criteria with a SpatialRestriction to solve my problem. This example searches all Regions that contain a given location where location here is a Geometry.
Criteria criteria = getCurrentSession().createCriteria(Region.class);
criteria.add(SpatialRestrictions.contains("theGeom", location));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With