3

I cannot find any way to use spatial criteria with Hibernate 5.2. Using criteria is not a problem:

CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(geoObjectClass);
Root<T> root = cq.from(geoObjectClass);
CriteriaQuery<T> critQuery = cq.select(root);
TypedQuery<T> query = entityManager.createQuery(critQuery);

But how can I add spatial restriction to this? E.g.

Criterion sr = SpatialRestrictions.distanceWithin("geometry", location, 0.1);

The 'Criterion'-interface is hibernate-specific and I cannot find how to apply it on the 'root' entity above. Is this possible at all?

Jeroen
  • 61
  • 4

0 Answers0