-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Can I use special operators in SQL queries with PosgreSQL?
PostPosted: Fri Apr 23, 2004 7:38 am 
Newbie

Joined: Fri Apr 23, 2004 7:14 am
Posts: 1
I want to implement persistence in a spatial database: PosgreSQL + PostGis extension. Can I use the spatial operators like && or distance?. Can I include calls to PostreSQL functions in the where statement?

Examples of some queries:

SELECT
ID, NAME
FROM ROADS_GEOM
WHERE
GEOM && GeometryFromText('POLYGON((191232 243117,191232 243119,191234 243117,191232 243117))',-1);


SELECT the_geom FROM geom_table
WHERE distance( the_geom, GeometryFromText( 'POINT(100000 200000)', -1 ) ) < 100

Thaks in advanced:
Fernando Z.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 23, 2004 7:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can use arbitary SQL functions in the where clause, but not in the select clause.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 12:25 am 
Newbie

Joined: Wed Oct 01, 2003 7:15 pm
Posts: 10
michael wrote:
You can use arbitary SQL functions in the where clause, but not in the select clause.


Did you mean that you can use arbitrary sql in the where clause with HQL or only with the native SQL connection?

I am also interested in using PostGIS with Hibernate...

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 1:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, special operators can appear in the HQL where clause, but cannot appear in the HQL select clause.

With the native JDBC connection you can do wahtever you like.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
also remember the createSQLQuery option.....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 6:29 pm 
Newbie

Joined: Wed Oct 01, 2003 7:15 pm
Posts: 10
The distinction being that HQL will return domain objects instead of resultsets.

Am I correct on this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 7:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nope.

createSQLQuery ONLY return domain objects.

HQL can return domain objects and/or scalar values.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 04, 2004 7:12 pm 
Newbie

Joined: Wed Oct 01, 2003 7:15 pm
Posts: 10
Wow...

thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.