Re: Deletion does not work; skips silently

From: Andrey Razumovsky (razumovsky.andre..mail.com)
Date: Sun Feb 14 2010 - 16:05:34 EST

  • Next message: Nishant Neeraj: "Re: Deletion does not work; skips silently"

    Are you launching those methods sequentally? Another question, are you sure
    positions.get(2) and proDetails are same objects? Do they have same
    persistence state? Try to figure that out printing
    System.out.println(proDetails) - it will show objectId and persistence
    state.
    Also check if there are DELETE statements generated for the object on line
    28

    2010/2/14 Nishant Neeraj <nneeraj12..ahoo.com>

    > Hi,
    >
    > I have a problem in deletion. When I try to fetch a list and delete a data
    > from the list (and commitChanges) in separate methods it does not work,
    > while the DataContext used is the same. There is no query-log or exception
    > for the case when not deleted.
    >
    > See the code below. Line 4 and 27 prints same HashCode. Line 18 deletes the
    > code successfully, while line 28 does not. Given that proDetails at line 24
    > is same as positions.get(2) of line 18.
    >
    >
    > [code]
    > 00000001 public List<ProfessionalDetails> getPositions(Users user){
    > 00000002
    > 00000003 DataContext dc = getDataContext();
    > 00000004 System.out.println("Data Context 1 >> " + dc.hashCode());
    > 00000005
    > 00000006 List<ProfessionalDetails> positions = null;
    > 00000007 Expression exp = Expression.fromString("user = $user and
    > proDetailType = $proType");
    > 00000008 HashMap hm = new HashMap();
    > 00000009 hm.put("user", user);
    > 00000010 hm.put("proType",
    > ProfessionalDetails.PRO_DETAIL_TYPE_POSITION);
    > 00000011 SelectQuery query = new
    > SelectQuery(ProfessionalDetails.class, exp.expWithParameters(hm));
    > 00000012 positions = dc.performQuery(query);
    > 00000013 List<Ordering> orderings = new ArrayList<Ordering>();
    > 00000014 orderings.add(new
    > Ordering("toDate",SortOrder.DESCENDING));
    > 00000015 orderings.add(new Ordering("fromDate",
    > SortOrder.DESCENDING));
    > 00000016 Ordering.orderList(positions, orderings);
    > 00000017 dc.commitChanges();
    > 00000018 //dc.deleteObject(positions.get(2));
    > 00000019 dc.commitChanges();
    > 00000020
    > 00000021 return positions;
    > 00000022 }
    > 00000023
    > 00000024 public void delete(ProfessionalDetails proDetails) {
    > 00000025
    > 00000026 DataContext dc = getDataContext();
    > 00000027 System.out.println("Data Context 2 >> " + dc.hashCode());
    > 00000028 dc.deleteObject(proDetails);
    > 00000029 dc.commitChanges();
    > 00000030 }
    >
    > [/code]
    >
    > Thanks
    > Nishant
    >
    >
    >
    > The INTERNET now has a personality. YOURS! See your Yahoo! Homepage.
    > http://in.yahoo.com/

    -- 
    Andrey
    



    This archive was generated by hypermail 2.0.0 : Sun Feb 14 2010 - 16:06:28 EST