Re: Raw delete

From: Michael Gentry (mgentr..asslight.net)
Date: Wed Oct 20 2010 - 18:02:41 UTC

  • Next message: caden whitaker: "Groovy + Cayenne (Dynamic Loading of Mapping Files)"

    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.
        dataContext.performNonSelectingQuery(chain);

    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.

    mrg

    On Wed, Oct 20, 2010 at 1:56 PM, <br..amp1.dmz.holos.pt> 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
    >
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Oct 20 2010 - 18:03:31 UTC