I don't think you will be able to do that with HQL, but you can execute
an arbitrary SQL similar to "select ST_TRANSFORM(geom...) as geom from foo"
I'm new to Hibernate and Hibernate Spatial, but I needed to execute
straight SQL and get geometries. Here's a code snippet that executes SQL
and returns geometries:
public List<ScheduleLine> getShapes(SchedQryHelper qh) {
String qry = "select * from schedule " + qh.getWhere();
SessionFactory f = null;
Session s = null;
List<ScheduleLine> sched = null;
try {
f = getHibernateTemplate().getSessionFactory();
s = f.openSession();
sched = s.createSQLQuery(qry)
.addEntity(ScheduleLine.class).list();
} catch(Exception e) {
logger.error(e.getMessage()+" whilst trying to execute HairyQuery: "+qry);
logger.error(e.toString()+e.getCause(),e);
} finally {
if(s != null)
s.close();
}
return sched;
}
ScheduleLine above is the object that represents the schedule table
which is a spatial table. I am running under spring and the
hibernateTemplate is a spring thing, so you may have to do something
different to obtain a session.
-Ted
Rafael Soto wrote:
> Hi Folks,
>
> I have one query in hql [ Select a from EntityA a, EntityB b where
> within(a.geo,b.geo) = TRUE ].
> All tables/relations in my database has a srid:4326.
> How can i transform all geometry datas in this query to another srid
> in the result of query?
> If i use Postgres SQL query it's only use a ST_TRANSFORM function in
> the geometry column result on the query. (I.E Select
> ST_TRANSFORM(a.the_geom) from TableA a )
>
>
> Hope for this answer
>
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users