hibernate-spatial

Hibernate Spatial - Query within an X kilometer radius?

大兔子大兔子 提交于 2019-12-02 17:43:16
I am new to Hibernate Spatial, and am trying to perform a simple query of objects within a given radius. I've created a number of entries in my database with properties corresponding to a latitude and longitude, using data from Google Maps and other sources. This property is defined like this in my Entity class: @Column @Type(type = "org.hibernate.spatial.GeometryType") private Point coordinates = null; I'm now trying to figure out how to do a search of all entity objects that have coordinates that fall within a radius of x kilometers from a given point. For example, I'd like to find objects

Received object of type org.postgresql.util.PGobject

只愿长相守 提交于 2019-12-01 09:01:31
I can insert geometry data into database from my code, but I can only query the data using an SQL editor, like PGAdmin III. I can't retrieve geometry data back to my code. Every attempt ends up with: "Received object of type org.postgresql.util.PGobject". Even running a simple query to test if two geometry values are equal, I get this error. 2017-09-11 19:04:47,771 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-37) /welcomePrimefaces.xhtml @46,106 actionListener="#{controlador.testar()}": java.lang.IllegalStateException: Received object of type org.postgresql.util

Received object of type org.postgresql.util.PGobject

我只是一个虾纸丫 提交于 2019-12-01 06:13:56
问题 I can insert geometry data into database from my code, but I can only query the data using an SQL editor, like PGAdmin III. I can't retrieve geometry data back to my code. Every attempt ends up with: "Received object of type org.postgresql.util.PGobject". Even running a simple query to test if two geometry values are equal, I get this error. 2017-09-11 19:04:47,771 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-37) /welcomePrimefaces.xhtml @46,106 actionListener=

Using JPA Criteria Api and hibernate spatial 4 together

别等时光非礼了梦想. 提交于 2019-11-27 23:11:10
Given the query example here: http://www.hibernatespatial.org/tutorial-hs4.html Query query = em.createQuery("select e from Event e where within(e.location, :filter) = true", Event.class); query.setParameter("filter", filter); Is it possible to rewrite the query using jpa 2 criteria api?( I am unsure how i should deal with the within(e.location, :filter) part. I recently work at the exact same problem. My solution is a own Predicate for the within-keyword. public class WithinPredicate extends AbstractSimplePredicate implements Serializable { private final Expression<Point> matchExpression;