How Use ST_TRANSFORM function in HQL

2 messages Options
Embed this post
Permalink
Rafael Soto-2

How Use ST_TRANSFORM function in HQL

Reply Threaded More More options
Print post
Permalink
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

--
RAFAEL Almeida Fernandez Soto :: [hidden email]
Consultant in Java Enterprise Edition
Consultant in FOSS GIS :: 55 21 2518-6233 :: 55 71 8802-0600
OpenGEO :: On-demand training and solutions :: www.opengeo.com.br
GEO Livre community:: Because Geoinformation should be free ::
www.geolivre.org.br
Be free by using Free Software, such as MapServer, PostgreSQL/PostGIS, gvSIG...
Linux User Number: 493334 ::
http://counter.li.org/cgi-bin/certificate.cgi/493334
_______________________________________________
hibernatespatial-users mailing list
[hidden email]
http://www.hibernatespatial.org/cgi-bin/mailman/listinfo/hibernatespatial-users
Ted Scott

Re: How Use ST_TRANSFORM function in HQL

Reply Threaded More More options
Print post
Permalink

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