Search code examples
javajpqlhibernate-4.xhibernate-spatial

Hibernate spatial functions keep throwing unexpected AST node


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.


Solution

  • 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