cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <>
Subject Re: Raw delete
Date Wed, 20 Oct 2010 18:02:41 GMT
I've done this in the past:

    QueryChain  chain = new QueryChain();

    // Add raw SQL templates to the chain.
    chain.addQuery(new SQLTemplate(Customer.class, "DELETE FROM Customers"));
    chain.addQuery(new SQLTemplate(Item.class, "DELETE FROM Items"));
    chain.addQuery(new SQLTemplate(LineItem.class, "DELETE FROM LineItems"));
    chain.addQuery(new SQLTemplate(Order.class, "DELETE FROM Orders"));

    // Execute all of the SQL statements.

Keep in mind that isn't a good thing to do if you are concerned about
your in-memory object graphs (DataContexts/etc) suddenly becoming
out-of-sync.  Also, if you don't need to do multiple deletes, you
don't need the query chain part.


On Wed, Oct 20, 2010 at 1:56 PM,  <> wrote:
> Hello all,
> Whats the better way to do a regular delete from in raw sql? I tried a raw
> sql named query on the modeler but i get a Null PK error, maybe because no
> data rows are returned?
> Thank you

View raw message