Some javascript/style in this post has been disabled (
why?)
Hello,
I use hibernatespatial with a Postgres/Postgis
database.
I use the HQL interface to query the database.
When I set the hibernate show_sql property to true, I
can see that the spatial index is not used as explained in the tutorial
(example with Criteria).
@Test
public void testIndexSpatial() throws
com.vividsolutions.jts.io.ParseException{
String hql = "SELECT
COUNT(md) FROM MDMetadata md LEFT JOIN md.identifications as a0 LEFT JOIN
a0.boundingPolygons as a1 WHERE intersects(a1.geometry, :g0) = true" ;
Query query =
((Session)getEntityManager().getDelegate()).createQuery(hql);
CustomType geometryType = new
CustomType(GeometryUserType.class, null);
WKTReader reader = new
WKTReader(new GeometryFactory(new
PrecisionModel(PrecisionModel.FLOATING_SINGLE), 4326));
query.setParameter("g0",
reader.read("POLYGON((-180 -90,-180 90,180 90, 180 -90, -180 -90))"),
geometryType);
Number result =
(Number)query.uniqueResult();
System.out.println(result);
}
Hibernate: select count(mdmetadata0_.id) as col_0_0_
from public.md_metadata mdmetadata0_ inner join public.mf_metadata
mdmetadata0_1_ on mdmetadata0_.id=mdmetadata0_1_.id left outer join
public.md_identification identifica1_ on mdmetadata0_.id=identifica1_.fk_md_metadata
left outer join public.ex_boundingpolygon boundingpo2_ on
identifica1_.id=boundingpo2_.fk_dataident where intersects(boundingpo2_.geom,
?)=true
I expected … where boundingpo2_.geom &&
? AND intersects(boundingpo2_.geom, ?)=true
Any Idea ?
Thanks a lot.
Vincent
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users