1. Query API
My classification of Cayenne queries is the following (ignore for a
moment 1.2 additions to the query package). SelectQuery,
ProcedureQuery, SQLTemplate are the three queries intended for public
use. All other queries are for internal use. You can use them in your
applications of course, but do it at your own risk. So looks like
what you need for deletion is SQLTemplate that of course can be
mapped in the Modeler.
2. Flushing invalid objects
Use DataContext.invalidateObjects(Collection). To invalidate all
registered objects you can do something like
dataContext.invalidateObjects(dataContext.getObjectStore().getObjects
());
3. NOT IN SelectQuery
> from contentType as type where type.id not in (select
> image.contentType
> from Image as img)
The closest thing without using SQLTemplate would be a query
following this FAQ - http://objectstyle.org/confluence/display/CAY/Not
+In+To+Many+FAQ E.g.:
// assuming you have a relationship "images" in ContentType object,
// this qualifier would filter content types that have at least one
image
Expression qualifier = Expression.fromString("images != null");
List excluded = ctxt.performQuery(new SelectQuery(ContentType.class,
qualifier));
List all = ctxt.performQuery(new SelectQuery(ContentType.class));
all.removeAll(excluded);
Andrus
On Sep 5, 2005, at 1:17 PM, Gili wrote:
> Ah! Good point.
>
> I'm having a hard time figuring out the query stuff (and Mike
> hasn't joined IRC today). Could you please try answering some of
> these related emails?
>
> http://objectstyle.org/cayenne/lists/cayenne-user/2005/09/0069.html
> http://objectstyle.org/cayenne/lists/cayenne-user/2005/09/0059.html
> http://objectstyle.org/cayenne/lists/cayenne-user/2005/09/0067.html
>
> I was going to try using DeleteBatchQuery (I saw an old email
> mentioning this is the preferred method under 1.2) but the Javadoc
> is very light and I don't understand how to use it. I want to
> conditionally delete all objects matching a certain qualifier but
> this qualifier involves an SQL nested query. I'm not sure how to
> represent this under Cayenne.
This archive was generated by hypermail 2.0.0 : Mon Sep 05 2005 - 13:48:31 EDT