Andrus Adamchik wrote:
> 2. Flushing invalid objects
>
> Use DataContext.invalidateObjects(Collection). To invalidate all registered objects you can do something like
>
> dataContext.invalidateObjects(dataContext.getObjectStore().getObjects ());
So if I wanted to synchronize Cayenne state after using a SQLTemplate
I'd have to invoke context.commitChanges() followed by
context.invalidateObjects(dataContext.getObjectStore().getObjects())?
Ideally I shouldn't have to commit the transaction yet. Is there a way
for me to tell Cayenne "for all objects in the ObjectStore, merge the
memory state with the DB state"?
> 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);
Ah! I keep on forgetting about these useful relationships! Though,
couldn't I just do this instead?
Expression qualifier = Expression.fromString("images = null");
List result = ctxt.performQuery(new SelectQuery(ContentType.class,
qualifier));
or is there a reason for using "all - excluded"?
Thank you,
Gili
This archive was generated by hypermail 2.0.0 : Mon Sep 05 2005 - 14:23:54 EDT