Re: deleting a row

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Sep 01 2003 - 17:05:48 EDT

  • Next message: Andrus Adamchik: "Cayenne Jobs"

    Hi,

    [This question belongs to cayenne-user list, so I am moving this thread
    there.]

    Anyway... You create a query, but you do not execute it anywhere.
    "commitChanges" is intended to commit changes to *objects*. Here you
    are basically building a raw SQL query that is unaware of any objects.
    Do something like:

      import org.objectstyle.cayenne.access.QueryResult;
      ....
      ctxt.performQuery(qry, new QueryResult());

    But.... are you sure this is what you are trying to achieve? Do you
    have an object with id = 43 in memory already? Then your example would
    look like this:

    Products objectToDelete;
    ctxt.deleteObject(objectToDelete);
    ctxt.commitChanges();

    Andrus

    On Monday, September 1, 2003, at 06:52 AM, G.Venu wrote:

    > hi all,
    >
    > I am a beginner to cayenne.i tried using this code for deleting a row
    > from a database.but nothing happend.could anyone help me out
    >
    > DataContext ctxt
    > =BasicServletConfiguration.getDefaultContext(request.getSession());
    > Expression qualifier =
    > ExpressionFactory.binaryPathExp(Expression.EQUAL_TO,
    > "productId","43"); DeleteQuery qry = new
    > DeleteQuery(Products.class,qualifier);
    > ctxt.commitChanges();
    >
    > thanks
    > venu
    >
    > --
    > With regards,
    >
    > Venu
    > --
    >



    This archive was generated by hypermail 2.0.0 : Mon Sep 01 2003 - 17:04:50 EDT