cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nishant Neeraj <nneeraj...@yahoo.com>
Subject Re: Deletion does not work; skips silently
Date Sun, 14 Feb 2010 21:49:17 GMT
Thanks for the quick reply; the tips really helped debugging.
My Bad. The two objects weren't the same -- in fact the one that I was trying to delete was
Transient.

In the same line, wouldn't It be nice if you try to delete a transient or non-registered object
and you see some kind of exception or log entry saying, 'trying to delete a transient entry.'

Anyways, thanks.

- Nishant

--- On Mon, 15/2/10, Andrey Razumovsky <razumovsky.andrey@gmail.com> wrote:

From: Andrey Razumovsky <razumovsky.andrey@gmail.com>
Subject: Re: Deletion does not work; skips silently
To: user@cayenne.apache.org
Date: Monday, 15 February, 2010, 2:35 AM

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 <nneeraj123@yahoo.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



      Your Mail works best with the New Yahoo Optimized IE8. Get it NOW! http://downloads.yahoo.com/in/internetexplorer/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message