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
This archive was generated by hypermail 2.0.0 : Sun Feb 14 2010 - 15:46:41 EST