Here is what I have tried but it returns a
"DoListItem" with null id and state as "hollow".
*************
String aDealId = "Deal_1";
String itemType="Type1";
String str="select dli.itemtype from dolistitem
dli,deal d WHERE (dli.deal_id=d.deal_id) AND
(d.dealnumber LIKE "+"'"+aDealId+"' )"+"AND
(dli.itemtype LIKE "+"'"+itemType+"')";
SQLTemplate query=new SQLTemplate(DoListItem.class,
str,true);
query.setFetchingDataRows(false);
List aa= dataContext.performQuery(query);
Iterator j=aa.iterator();
while(j.hasNext())
{
DoListItem d=(DoListItem)j.next();
System.out.println(d);
}
Am I doing something wrong here?
Thanks,
Denna
--- Andrus Adamchik <andru..bjectstyle.org> wrote:
> It is definitely possible to fetch DataObjects with
> SQLTemplate by
> using the right column names (and calling
> "setFetchingDataRows
> (false)" before the fetch), but before you go in
> this direction, make
> sure it is not possible to use a simple SelectQuery
> (e.g. if you are
> using aggregate functions in qualifier).
>
> And finally chances are your related DoListItems are
> already in
> memory, and you can simply iterate over a list
> returned from a a Deal
> XYZ relationship, check which object(s) match the
> condition and
> delete this object.
>
> Andrus
>
>
>
> On Jun 6, 2005, at 4:11 PM, Dhruti Ramani wrote:
> > Thanks, I have read about that. Thats what I was
> trying to do. I
> > was trying to get object from database and then
> use deleteObject
> > method. But my query depends on two tables and I
> dont know how to
> > get hold of particular object. If I use
> SQLTemplate it return
> > results in turms of Map, but I need to get Object
> to delete it.
> >
> > Is there any other way to do this?
> > Thanks,
> > Denna
> > Andrus Adamchik <andru..bjectstyle.org> wrote:
> > Denna,
> >
> > You better avoid deleting data from DB directly.
> You may end up with
> > an inconsistent object graph ... and generally if
> you work in the ORM
> > object space, why bother with SQL.
> >
> > So just get a hold of an object in question and
> then do:
> >
> > dataContext.deleteObject(object);
> > dataContext.commitChanges()
> >
> > Andrus
> >
> >
> > On Jun 6, 2005, at 11:51 AM, Dhruti Ramani wrote:
> > > Hi,
> > >
> > > I have to remove a DoListItem whose type is
> 'xyz' for particular
> > > Deal (so basically query uses two tables). How
> do I delete that
> > > particular object? I was trying to use
> SQLTemplate but it returns
> > > Map so i can not bind that to particular object.
> > >
> > > Any ideal?
> > > Thanks,
> > > Denna
> >
> > Discover Yahoo!
> > Have fun online with music videos, cool games, IM
> & more. Check it
> > out!
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This archive was generated by hypermail 2.0.0 : Tue Jun 07 2005 - 09:06:22 EDT