The best practice approach is to have separate <insert> statements and call each individually from with your DAO code within a normal for loop. The <iterate> element was never meant to be used for supporting multiple insert/update/delete statements.
This is a common confusion. Perhaps something in the FAQ would be a good idea. Clinton On Tue, 1 Feb 2005 10:52:57 -0500, Akins, Greg <[EMAIL PROTECTED]> wrote: > > Trying to find the best approach to a 1:M relationship. > (Apologize ahead if I'm missing something) > > > class master { > private List children ; > public void setChildren(List list){} > public List getChildren() {} > } > > The suggestions from the mail archives seem to indicate two possibilities > > <sqlMap... > insert into master values(...) ; > <iterate id=children> > insert into Childvalues(..) ; > </iterate> > </sqlMap > > or.... > > Master master = new Master() ; > > Child child = new Child() ; > master.getChildren().add(child) ; > > MasterDAO.save(master) ; > > child.setParent(master) ; > ChildDAO.save(child) ; > > Using the first approach causes me to create multiple insert statements for > a "Child" insert (One in the Master mapping, one in the child mapping... Is > there a way to define links to other statements? > Using the second approach causes me to use "Relational" constructs to > describe a Object mapping. > > > > > Greg Akins > Software Engineer > Sony Electronics, STP Systems > 724.696.7322 (Sony) > 724.696.6147 (AV) > 724.454.7790 (Cell) > 412.590.3973 (Pager) >