db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andras Balogh <and...@reea.net>
Subject Re: Documentation and (slightly) strange update problem
Date Wed, 25 Feb 2004 15:08:24 GMT
Hello,

What about using the Criteria Object?

Critetria crit=new Criteria();
crit.add(ObjcontentPeer.folderID,folder.getObjid());
crit.add(ObjcontentPeer.OBJ_ID,getObjid());
List l=ObjcontentPeer.doSelect(crit);


Best wishes,
Andras.

raph@mankin.org.uk wrote:

>As requested, here is the code
>
>
>     /*
>       This does not work. Since we retrieved using two column values
>       it will save using those same two column values, but one of them
>       has changed, so the save will fail.
>      Objcontent link = new Objcontent(folder.getObjid(), getObjid());
>      List l = ObjcontentPeer.doSelect(link);
>      link = (Objcontent) l.get(0); // There can only be one instance
>      link.setFolderid(parent.getObjid());
>      link.save(); // This is the save() that does an INSERT instead of an
>UPDATE
>      */
>
>
>// This one does work.
>     List l = getObjcontentsRelatedByContentid();
>LINK_UPDATE:
>         /*
>          This does work because we retrieve by PK and so the save will be by PK
>          */
>     for (Iterator iter = l.iterator(); iter.hasNext(); ) {
>       Objcontent link = (Objcontent) (iter.next());
>       if (link.getFolderid() == folder.getObjid()) {
>         link.setFolderid(parent.getObjid());
>         link.save();
>         break LINK_UPDATE;
>        }
>     }
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message