Hello all,
I'm having a bit of a problem executing a spatial query (query with some
custom parts). I used to do queries this way:
================
SelectQuery query = new SelectQuery(Opleiding.class, qual);
Ordering ordering = new Ordering("waardeopleiding.naam", Ordering.ASC);
query.addOrdering(ordering);
query.addPrefetch("waardeopleiding");
List opleidingen = ctxt.performQuery(query);
================
I was just using SelectQuery which was the easiest way. I could prefetch
the relationships and everything went fine.
But now i need to add a non standard query part to the sql. It's something
like this:
================
where.add(" (opleiding.the_geom && GeometryFromText('BOX3D(" +
"" + (x - radius) + " " + (y - radius) + ", " +
"" + (x + radius) + " " + (y + radius) +
")'::box3d,-1) and " +
"distance(opleiding.the_geom, GeometryFromText('POINT(" + x +
" " +
y + ")',-1)) < " + radius + ") ");
================
I discovered quickly that this was not possible with SelectQuery :-) So i
found SQLTemplate, which allows me to specify a not standard query.
=================
String query=".." //query with a lot of joins and non standard where statements
SQLTemplate rawSelect = new SQLTemplate(Opleiding.class, query, true);
List opleidingen = ctxt.performQuery(rawSelect);
=================
The List "opleidingen" will contain object of type "Opleiding.class". The
Opleiding.class has a one to one relationship with another object.
Is it possible to prefetch relationships when using SQLTemplate?
Or should i just use direct sql on my database (without cayenne), i guess
that will be possible (without conflicting with cayenne) because i only use
select queries with these non standard sql. For the rest i use cayenne
functions.
Cheers,
Twan
This archive was generated by hypermail 2.0.0 : Tue Aug 24 2004 - 07:59:39 EDT