ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Akins, Greg" <gak...@amervideo.com>
Subject 1:M relations, cascading inserts, etc...
Date Tue, 01 Feb 2005 15:52:57 GMT
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)
 

Mime
View raw message