Wow, you just gave me a Star Wars flashback. If we make it to C3PO,
we'll be *golden*! :-)
If you want to execute that exact SQL, you could do it with
SQLTemplate. For example, in one of my demo/test projects, I have:
sqlQuery = new SQLTemplate(Order.class, "DELETE FROM Orders");
dataContext.performNonSelectingQuery(sqlQuery);
If you need it more dynamic, look at inExp() on this page:
http://cayenne.apache.org/doc/expression-factory-utilities.html
You'd then make an Expression and perform query them/fetch them, then
delete them. There might be an easier way to do this, but I know this
approach would keep your Cayenne object graph in sync (the SQLTemplate
can get things out of sync). Something like:
Expression exp = ExpressionFactory.inExp("oid", values);
SelectQuery select = new SelectQuery(Artist.class, exp);
List list = dataContext.performQuery(select);
// loop over list and:
dataContext.deleteObject(item);
// then save
dataContext.commitChanges();
/dev/mrg
PS. The "oid" field needs to be mapped in the above example ...
On Fri, May 30, 2008 at 9:27 AM, Borut Bolina <borut.bolcina@gmail.com> wrote:
> Hi,
>
> what is the C3M4 prefered way of doing this SQL equivalent: DELETE FROM
> Artist WHERE Oid IN (1,4,8,9);
>
> Thanks,
> Borut
>
This archive was generated by hypermail 2.0.0 : Fri May 30 2008 - 09:43:22 EDT