Are you using turbine 2.1? It's been fixed in cvs. The problem was with the call to copyObj.getBars(). When the copyObj is created, isNew is true. When getBars() is called, if the object is new, there is no reason to retrieve the bar objects ( since there shouldn't be any ). The fix was to set copyObject.setNew( false ), copy the dependant objects, then set copyObject.setNew( true ). Patch committed in cvs to turbine-2 and turbine-torque back on 10/19/2001.
Options: o Look into the archives on how to move up to cvs version of turbine-2 o Wait until 2.2 is released o Use stand-alone torque from cvs o Patch your copy of Object.vm, look in cvsweb on jakarta site for the change on 10/19, it is two lines of code: http://cvs.apache.org/viewcvs/jakarta-turbine-2/conf/torque/templates/om/Obj ect.vm.diff?r1=1.1&r2=1.2 ----------------------------------------------------------------- Jeffrey D. Brekke Quad/Graphics [EMAIL PROTECTED] http://www.qg.com ----------------------------------------------------------------- > -----Original Message----- > From: Nick Pomfret [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 27, 2001 2:05 PM > To: [EMAIL PROTECTED] > Subject: possible bug in torque generated code > > > The copy() method in the torque generated in the object model > doesn't seem > to work as I would expect. > > When using the copy() method on an object it correctly copies > that object > but not those objects dependent upon it. Looking at the automatically > generated code it would appear that copying dependent objects > is what is > supposed to happen (see torque-generated code below for the > class 'Foo', > which contains other objects 'Bar') - am I correct? > > public Foo copy() throws Exception > { > Foo copyObj = new Foo(); > copyObj.setFooId(foo_id); > > v = copyObj.getBars(); > for (int i=0; i<v.size(); i++) > { > ((Persistent)v.get(i)).setNew(true); > } > > copyObj.setFooId((NumberKey)null); > return copyObj; > } > > The copyObj is created at the start of this method and so > never has any > 'Bars', why then call 'getBars()' as the result will always > be an empty > vector? > > Assuming I've not got the wrong end of the stick completely, would the > following be an adequate solution? > > public Foo copy() throws Exception > { > Foo copyObj = new Foo(); > copyObj.setFooId(foo_id); > > v = getBars(); > for (int i=0; i<v.size(); i++) > { > Bar obj = (Bar) v.get(i); > copyObj.addBar(obj.copy()); > ((Persistent)v.get(i)).setNew(true); > } > > copyObj.setFooId((NumberKey)null); > return copyObj; > } > > If so, Object.vm (in torque) would need to be modified so > that the code > which generates the changes described is: > > ${list}v = get${pCollName}(); > for (int i=0; i<v.size(); i++) > { > $className obj = ($className) v.get(i); > copyObj.add$className(obj.copy()) > ((Persistent)v.get(i)).setNew(true); > } > > I'm new to this stuff so forgive me if I've miss understood! > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>