[hibernate-dev] HQL and spatial

Steve Ebersole steve at hibernate.org
Thu Sep 10 08:12:14 EDT 2015


>
> It is true that not all applications use spatial, or even that DB’s
> support (all) spatial functions. But it would help to ensure consistency in
> the available dialects. Now this consistency is tested for in the
> integration tests, so not having this at the grammar isn’t a big problem.
>

Its up to you.  We can add it to the grammar and simply have it throw
exceptions if those functions are not understood.


Support for spatial literals would be a great plus. In my opinion, the best
> candidate for HQL spatial literals is the Postgis EWKT format (
> http://postgis.net/docs/manual-2.1/using_postgis_dbmanagement.html#EWKB_EWKT),
> which is a sane, and popular extension of the purely 2D WKT standard. It
> is  supported in the geolatte-geom library and many others. I can help by
> writing a grammar for this.
>

What I have done thus far in SQM grammars is to borrow from the idea of
"JDBC escape syntax".  So for example, to define a timestamp literal one
would say `{ts '2015-10-10 ...'}`


There is also at least one HQL syntax change that would help implement
> spatial functions:  function invocations that evaluate to boolean should be
> regarded as valid boolean expressions. The HQL currently doesn’t seem to
> allow this, so I needed to wrap them in equality expressions. But then
> MySQL wouldn’t use its spatial index (as I wrote before, although I
> mistakenly wrote “spatial query” in my original email).
>

This would require some knowledge of the "metadata" of a function, which is
not there in SQM at all so far.  Here, I'd have to know the return type of
the referenced function.  We can contemplate that.
https://hibernate.atlassian.net/browse/SQM-15


More information about the hibernate-dev mailing list