[postgis-users] Postgis Java Geometry classes/Hibernate, borken query[Solution]

Dave Potts dave.potts at pinan.co.uk
Fri Dec 1 12:06:13 PST 2006


Dave Potts wrote:
> Hi Folks
>
> I am using hibernate to query a postgis database.
>
> The majority of my distance queries work as expected, one does not!
> For one distance setting I get loads of answers, for a greater 
> distance, I get none, when I would expect to get at least the first set.
>
> So I suspect that either Hibernate or Postgis are having problems.
>
> I can type the query in by hand and it works as expected , so I don't 
> suspect the database or postgis interface to the database.
>
> Is there any debug code in postgres/postgi/Hibernate that will actual 
> allow me work out what data is being sent from postgres to hibernate, 
> what hibernate is caching and what its forwarding to the end user.
>
> regards David
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   
I found the problem,  my hibernate query said something like 

blah blah blah manor.geometry is not null and distance(manor.geometry, 
srcCastle.geometry)  < :distance

I was setting the value of distance by saying

query.setString("distance","3000");

Distance is a numerical construct

as soon as I said
query.setInteger("distance",3000);

It now works as expected !
Its at times like this, I remeber Pascal and its very rigid views about 
argument types.

It has taken some 7 hours to find this problem.

David.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: dave.potts.vcf
Type: text/x-vcard
Size: 85 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20061201/300bf9df/attachment.vcf>


More information about the postgis-users mailing list