You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by soussou97 <db...@yahoo.fr> on 2006/10/17 17:01:23 UTC

Composite objects

Hi;

I have a two java Beans as follows :

public class Person implements serializable {
    private Name name;
    private String key;
    private List account = new ArrayList();


    public String getKey() {
        return key;
    }
    private void setKey(String key) {
        this.key=key;
    }
       public Name getName() {
        return name;
    }
    public void setName(Name name) {
        this.name = name;
    }
    public void setAccount(List accounts) {
        this.accounts = accounts;
  }

  public List getAccounts() {
        return account;
  }
    ......
}

public class Account implements Serializable {

  private String username;
  private String password;
  private String email;
  private String firstName;
  private String lastName;
  private String status;
  
    
  public String getUsername() {
    return username;
  }

  public void setUsername(String username) {
    this.username = username;
  }

  public String getPassword() {
    return password;
  }

  public void setPassword(String password) {
    this.password = password;
  }

  public String getEmail() {
    return email;
  }

  public void setEmail(String email) {
    this.email = email;
  }

  public String getFirstName() {
    return firstName;
  }

  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }

  public String getLastName() {
    return lastName;
  }

  public void setLastName(String lastName) {
    this.lastName = lastName;
  }

  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
    this.status = status;
  }

 }
And I would like to realize the method DAO for creating a new person with
its accounts, getting all person into the database with the accounts and
updating a person with its accounts.
I have the following methodes DAO :

insertAccount(Account a)
insertPerson (Person p)
UpdateAccount(Account a)
UpdatePerson(Person p)
getAllPerson(String key)
getAllAccount(String name, String password)

Question : how I must realize the link between the two objects, for example
for the "insertPerson" DAO, I must firstly to insert the liste of accounts
next the person or inside of the method "insertPerson" DAO I call
"insertAccount" DAO to get the list of accounts ?
In the same way for the "getAllPerson" which return a Person object.

Generally how to implement the composite objects with Ibatis.

Regards;

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by soussou97 <db...@yahoo.fr>.
Thank's Larry;

"For writing, you just have to do the parent, then the children in order" =>
have you please an example ? 


Larry Meadors-2 wrote:
> 
> For fetching from the database:
> 
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> 
> For writing, you just have to do the parent, then the children in order.
> 
> Larry
> 
> 
> On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>>
>> Hi;
>>
>> I have a two java Beans as follows :
>>
>> public class Person implements serializable {
>>     private Name name;
>>     private String key;
>>     private List account = new ArrayList();
>>
>>
>>     public String getKey() {
>>         return key;
>>     }
>>     private void setKey(String key) {
>>         this.key=key;
>>     }
>>        public Name getName() {
>>         return name;
>>     }
>>     public void setName(Name name) {
>>         this.name = name;
>>     }
>>     public void setAccount(List accounts) {
>>         this.accounts = accounts;
>>   }
>>
>>   public List getAccounts() {
>>         return account;
>>   }
>>     ......
>> }
>>
>> public class Account implements Serializable {
>>
>>   private String username;
>>   private String password;
>>   private String email;
>>   private String firstName;
>>   private String lastName;
>>   private String status;
>>
>>
>>   public String getUsername() {
>>     return username;
>>   }
>>
>>   public void setUsername(String username) {
>>     this.username = username;
>>   }
>>
>>   public String getPassword() {
>>     return password;
>>   }
>>
>>   public void setPassword(String password) {
>>     this.password = password;
>>   }
>>
>>   public String getEmail() {
>>     return email;
>>   }
>>
>>   public void setEmail(String email) {
>>     this.email = email;
>>   }
>>
>>   public String getFirstName() {
>>     return firstName;
>>   }
>>
>>   public void setFirstName(String firstName) {
>>     this.firstName = firstName;
>>   }
>>
>>   public String getLastName() {
>>     return lastName;
>>   }
>>
>>   public void setLastName(String lastName) {
>>     this.lastName = lastName;
>>   }
>>
>>   public String getStatus() {
>>     return status;
>>   }
>>
>>   public void setStatus(String status) {
>>     this.status = status;
>>   }
>>
>>  }
>> And I would like to realize the method DAO for creating a new person with
>> its accounts, getting all person into the database with the accounts and
>> updating a person with its accounts.
>> I have the following methodes DAO :
>>
>> insertAccount(Account a)
>> insertPerson (Person p)
>> UpdateAccount(Account a)
>> UpdatePerson(Person p)
>> getAllPerson(String key)
>> getAllAccount(String name, String password)
>>
>> Question : how I must realize the link between the two objects, for
>> example
>> for the "insertPerson" DAO, I must firstly to insert the liste of
>> accounts
>> next the person or inside of the method "insertPerson" DAO I call
>> "insertAccount" DAO to get the list of accounts ?
>> In the same way for the "getAllPerson" which return a Person object.
>>
>> Generally how to implement the composite objects with Ibatis.
>>
>> Regards;
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6857676
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by soussou97 <db...@yahoo.fr>.
Hi Jeff;

I search an example more complicated with a List of List of objects :

CategorisedProductList with properties
Category supercat;
List [cat] [product]

and 3 tables:  supercat => 1..* cat => 1..* product 

Regards;






 


Jeff Butler-2 wrote:
> 
> Here's an example from JPetStore 5:
> 
> http://svn.apache.org/repos/asf/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java
> 
> Look at the insertOrder method.
> 
> That example application shows several good design patterns.
> 
> Jeff Butler
> 
> 
> On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>>
>>
>> Hi;
>>
>> I try to understand with the example :
>>
>> CategorisedProductList with properties
>> Category cat;
>> List<Product> prodList;
>>
>> Category with properties
>> Integer catid;
>> String catname;
>>
>> Product with properties
>> Integer prodid;
>> String prodname;
>>
>> The insertProductDAO and insertCategoryDAO must be implemented with
>> CategorisedProductList (as the method "getProductListByCategory") or with
>> the objets produtc and category and how are realized the calls ?
>> Somebody will be able to give me an example for that !
>>
>> Thank's
>>
>>
>> Larry Meadors-2 wrote:
>> >
>> > For fetching from the database:
>> >
>> >
>> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
>> >
>> > For writing, you just have to do the parent, then the children in
>> order.
>> >
>> > Larry
>> >
>> >
>> > On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>> >>
>> >> Hi;
>> >>
>> >> I have a two java Beans as follows :
>> >>
>> >> public class Person implements serializable {
>> >>     private Name name;
>> >>     private String key;
>> >>     private List account = new ArrayList();
>> >>
>> >>
>> >>     public String getKey() {
>> >>         return key;
>> >>     }
>> >>     private void setKey(String key) {
>> >>         this.key=key;
>> >>     }
>> >>        public Name getName() {
>> >>         return name;
>> >>     }
>> >>     public void setName(Name name) {
>> >>         this.name = name;
>> >>     }
>> >>     public void setAccount(List accounts) {
>> >>         this.accounts = accounts;
>> >>   }
>> >>
>> >>   public List getAccounts() {
>> >>         return account;
>> >>   }
>> >>     ......
>> >> }
>> >>
>> >> public class Account implements Serializable {
>> >>
>> >>   private String username;
>> >>   private String password;
>> >>   private String email;
>> >>   private String firstName;
>> >>   private String lastName;
>> >>   private String status;
>> >>
>> >>
>> >>   public String getUsername() {
>> >>     return username;
>> >>   }
>> >>
>> >>   public void setUsername(String username) {
>> >>     this.username = username;
>> >>   }
>> >>
>> >>   public String getPassword() {
>> >>     return password;
>> >>   }
>> >>
>> >>   public void setPassword(String password) {
>> >>     this.password = password;
>> >>   }
>> >>
>> >>   public String getEmail() {
>> >>     return email;
>> >>   }
>> >>
>> >>   public void setEmail(String email) {
>> >>     this.email = email;
>> >>   }
>> >>
>> >>   public String getFirstName() {
>> >>     return firstName;
>> >>   }
>> >>
>> >>   public void setFirstName(String firstName) {
>> >>     this.firstName = firstName;
>> >>   }
>> >>
>> >>   public String getLastName() {
>> >>     return lastName;
>> >>   }
>> >>
>> >>   public void setLastName(String lastName) {
>> >>     this.lastName = lastName;
>> >>   }
>> >>
>> >>   public String getStatus() {
>> >>     return status;
>> >>   }
>> >>
>> >>   public void setStatus(String status) {
>> >>     this.status = status;
>> >>   }
>> >>
>> >>  }
>> >> And I would like to realize the method DAO for creating a new person
>> with
>> >> its accounts, getting all person into the database with the accounts
>> and
>> >> updating a person with its accounts.
>> >> I have the following methodes DAO :
>> >>
>> >> insertAccount(Account a)
>> >> insertPerson (Person p)
>> >> UpdateAccount(Account a)
>> >> UpdatePerson(Person p)
>> >> getAllPerson(String key)
>> >> getAllAccount(String name, String password)
>> >>
>> >> Question : how I must realize the link between the two objects, for
>> >> example
>> >> for the "insertPerson" DAO, I must firstly to insert the liste of
>> >> accounts
>> >> next the person or inside of the method "insertPerson" DAO I call
>> >> "insertAccount" DAO to get the list of accounts ?
>> >> In the same way for the "getAllPerson" which return a Person object.
>> >>
>> >> Generally how to implement the composite objects with Ibatis.
>> >>
>> >> Regards;
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
>> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-objects-tf2460146.html#a6864096
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6892763
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by soussou97 <db...@yahoo.fr>.
Hi Jeff;

Thank's for the example. So the "CategorisedProductList" java bean is useful
only for fetching from the database ?
This Java bean must respect java bean conventions: default constructor,
serialzable, .. or not ?

Regards;


Jeff Butler-2 wrote:
>  wrote:
>>
>>
>> Hi;
>>
>> I try to understand with the example :
>>
>> CategorisedProductList with properties
>> Category cat;
>> List<Product> prodList;
>>
>> Category with properties
>> Integer catid;
>> String catname;
>>
>> Product with properties
>> Integer prodid;
>> String prodname;
>>
>> The insertProductDAO and insertCategoryDAO must be implemented with
>> CategorisedProductList (as the method "getProductListByCategory") or with
>> the objets produtc and category and how are realized the calls ?
>> Somebody will be able to give me an example for that !
>>
>> Thank's
>>
>>
>> Larry Meadors-2 wrote:
>> >
>> > For fetching from the database:
>> >
>> >
>> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
>> >
>> > For writing, you just have to do the parent, then the children in
>> order.
>> >
>> > Larry
>> >
>> >
>> > On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>> >>
>> >> Hi;
>> >>
>> >> I have a two java Beans as follows :
>> >>
>> >> public class Person implements serializable {
>> >>     private Name name;
>> >>     private String key;
>> >>     private List account = new ArrayList();
>> >>
>> >>
>> >>     public String getKey() {
>> >>         return key;
>> >>     }
>> >>     private void setKey(String key) {
>> >>         this.key=key;
>> >>     }
>> >>        public Name getName() {
>> >>         return name;
>> >>     }
>> >>     public void setName(Name name) {
>> >>         this.name = name;
>> >>     }
>> >>     public void setAccount(List accounts) {
>> >>         this.accounts = accounts;
>> >>   }
>> >>
>> >>   public List getAccounts() {
>> >>         return account;
>> >>   }
>> >>     ......
>> >> }
>> >>
>> >> public class Account implements Serializable {
>> >>
>> >>   private String username;
>> >>   private String password;
>> >>   private String email;
>> >>   private String firstName;
>> >>   private String lastName;
>> >>   private String status;
>> >>
>> >>
>> >>   public String getUsername() {
>> >>     return username;
>> >>   }
>> >>
>> >>   public void setUsername(String username) {
>> >>     this.username = username;
>> >>   }
>> >>
>> >>   public String getPassword() {
>> >>     return password;
>> >>   }
>> >>
>> >>   public void setPassword(String password) {
>> >>     this.password = password;
>> >>   }
>> >>
>> >>   public String getEmail() {
>> >>     return email;
>> >>   }
>> >>
>> >>   public void setEmail(String email) {
>> >>     this.email = email;
>> >>   }
>> >>
>> >>   public String getFirstName() {
>> >>     return firstName;
>> >>   }
>> >>
>> >>   public void setFirstName(String firstName) {
>> >>     this.firstName = firstName;
>> >>   }
>> >>
>> >>   public String getLastName() {
>> >>     return lastName;
>> >>   }
>> >>
>> >>   public void setLastName(String lastName) {
>> >>     this.lastName = lastName;
>> >>   }
>> >>
>> >>   public String getStatus() {
>> >>     return status;
>> >>   }
>> >>
>> >>   public void setStatus(String status) {
>> >>     this.status = status;
>> >>   }
>> >>
>> >>  }
>> >> And I would like to realize the method DAO for creating a new person
>> with
>> >> its accounts, getting all person into the database with the accounts
>> and
>> >> updating a person with its accounts.
>> >> I have the following methodes DAO :
>> >>
>> >> insertAccount(Account a)
>> >> insertPerson (Person p)
>> >> UpdateAccount(Account a)
>> >> UpdatePerson(Person p)
>> >> getAllPerson(String key)
>> >> getAllAccount(String name, String password)
>> >>
>> >> Question : how I must realize the link between the two objects, for
>> >> example
>> >> for the "insertPerson" DAO, I must firstly to insert the liste of
>> >> accounts
>> >> next the person or inside of the method "insertPerson" DAO I call
>> >> "insertAccount" DAO to get the list of accounts ?
>> >> In the same way for the "getAllPerson" which return a Person object.
>> >>
>> >> Generally how to implement the composite objects with Ibatis.
>> >>
>> >> Regards;
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
>> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-objects-tf2460146.html#a6864096
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6871131
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by Jeff Butler <je...@gmail.com>.
Here's an example from JPetStore 5:

http://svn.apache.org/repos/asf/ibatis/trunk/java/jpetstore/jpetstore5/src/com/ibatis/jpetstore/persistence/sqlmapdao/OrderSqlMapDao.java

Look at the insertOrder method.

That example application shows several good design patterns.

Jeff Butler


On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>
>
> Hi;
>
> I try to understand with the example :
>
> CategorisedProductList with properties
> Category cat;
> List<Product> prodList;
>
> Category with properties
> Integer catid;
> String catname;
>
> Product with properties
> Integer prodid;
> String prodname;
>
> The insertProductDAO and insertCategoryDAO must be implemented with
> CategorisedProductList (as the method "getProductListByCategory") or with
> the objets produtc and category and how are realized the calls ?
> Somebody will be able to give me an example for that !
>
> Thank's
>
>
> Larry Meadors-2 wrote:
> >
> > For fetching from the database:
> >
> >
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> >
> > For writing, you just have to do the parent, then the children in order.
> >
> > Larry
> >
> >
> > On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
> >>
> >> Hi;
> >>
> >> I have a two java Beans as follows :
> >>
> >> public class Person implements serializable {
> >>     private Name name;
> >>     private String key;
> >>     private List account = new ArrayList();
> >>
> >>
> >>     public String getKey() {
> >>         return key;
> >>     }
> >>     private void setKey(String key) {
> >>         this.key=key;
> >>     }
> >>        public Name getName() {
> >>         return name;
> >>     }
> >>     public void setName(Name name) {
> >>         this.name = name;
> >>     }
> >>     public void setAccount(List accounts) {
> >>         this.accounts = accounts;
> >>   }
> >>
> >>   public List getAccounts() {
> >>         return account;
> >>   }
> >>     ......
> >> }
> >>
> >> public class Account implements Serializable {
> >>
> >>   private String username;
> >>   private String password;
> >>   private String email;
> >>   private String firstName;
> >>   private String lastName;
> >>   private String status;
> >>
> >>
> >>   public String getUsername() {
> >>     return username;
> >>   }
> >>
> >>   public void setUsername(String username) {
> >>     this.username = username;
> >>   }
> >>
> >>   public String getPassword() {
> >>     return password;
> >>   }
> >>
> >>   public void setPassword(String password) {
> >>     this.password = password;
> >>   }
> >>
> >>   public String getEmail() {
> >>     return email;
> >>   }
> >>
> >>   public void setEmail(String email) {
> >>     this.email = email;
> >>   }
> >>
> >>   public String getFirstName() {
> >>     return firstName;
> >>   }
> >>
> >>   public void setFirstName(String firstName) {
> >>     this.firstName = firstName;
> >>   }
> >>
> >>   public String getLastName() {
> >>     return lastName;
> >>   }
> >>
> >>   public void setLastName(String lastName) {
> >>     this.lastName = lastName;
> >>   }
> >>
> >>   public String getStatus() {
> >>     return status;
> >>   }
> >>
> >>   public void setStatus(String status) {
> >>     this.status = status;
> >>   }
> >>
> >>  }
> >> And I would like to realize the method DAO for creating a new person
> with
> >> its accounts, getting all person into the database with the accounts
> and
> >> updating a person with its accounts.
> >> I have the following methodes DAO :
> >>
> >> insertAccount(Account a)
> >> insertPerson (Person p)
> >> UpdateAccount(Account a)
> >> UpdatePerson(Person p)
> >> getAllPerson(String key)
> >> getAllAccount(String name, String password)
> >>
> >> Question : how I must realize the link between the two objects, for
> >> example
> >> for the "insertPerson" DAO, I must firstly to insert the liste of
> >> accounts
> >> next the person or inside of the method "insertPerson" DAO I call
> >> "insertAccount" DAO to get the list of accounts ?
> >> In the same way for the "getAllPerson" which return a Person object.
> >>
> >> Generally how to implement the composite objects with Ibatis.
> >>
> >> Regards;
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
> >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Composite-objects-tf2460146.html#a6864096
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Re: Composite objects

Posted by soussou97 <db...@yahoo.fr>.
Hi;

I try to understand with the example :

CategorisedProductList with properties
Category cat;
List<Product> prodList;

Category with properties
Integer catid;
String catname;

Product with properties
Integer prodid;
String prodname;

The insertProductDAO and insertCategoryDAO must be implemented with
CategorisedProductList (as the method "getProductListByCategory") or with
the objets produtc and category and how are realized the calls ?
Somebody will be able to give me an example for that !

Thank's


Larry Meadors-2 wrote:
> 
> For fetching from the database:
> 
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> 
> For writing, you just have to do the parent, then the children in order.
> 
> Larry
> 
> 
> On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>>
>> Hi;
>>
>> I have a two java Beans as follows :
>>
>> public class Person implements serializable {
>>     private Name name;
>>     private String key;
>>     private List account = new ArrayList();
>>
>>
>>     public String getKey() {
>>         return key;
>>     }
>>     private void setKey(String key) {
>>         this.key=key;
>>     }
>>        public Name getName() {
>>         return name;
>>     }
>>     public void setName(Name name) {
>>         this.name = name;
>>     }
>>     public void setAccount(List accounts) {
>>         this.accounts = accounts;
>>   }
>>
>>   public List getAccounts() {
>>         return account;
>>   }
>>     ......
>> }
>>
>> public class Account implements Serializable {
>>
>>   private String username;
>>   private String password;
>>   private String email;
>>   private String firstName;
>>   private String lastName;
>>   private String status;
>>
>>
>>   public String getUsername() {
>>     return username;
>>   }
>>
>>   public void setUsername(String username) {
>>     this.username = username;
>>   }
>>
>>   public String getPassword() {
>>     return password;
>>   }
>>
>>   public void setPassword(String password) {
>>     this.password = password;
>>   }
>>
>>   public String getEmail() {
>>     return email;
>>   }
>>
>>   public void setEmail(String email) {
>>     this.email = email;
>>   }
>>
>>   public String getFirstName() {
>>     return firstName;
>>   }
>>
>>   public void setFirstName(String firstName) {
>>     this.firstName = firstName;
>>   }
>>
>>   public String getLastName() {
>>     return lastName;
>>   }
>>
>>   public void setLastName(String lastName) {
>>     this.lastName = lastName;
>>   }
>>
>>   public String getStatus() {
>>     return status;
>>   }
>>
>>   public void setStatus(String status) {
>>     this.status = status;
>>   }
>>
>>  }
>> And I would like to realize the method DAO for creating a new person with
>> its accounts, getting all person into the database with the accounts and
>> updating a person with its accounts.
>> I have the following methodes DAO :
>>
>> insertAccount(Account a)
>> insertPerson (Person p)
>> UpdateAccount(Account a)
>> UpdatePerson(Person p)
>> getAllPerson(String key)
>> getAllAccount(String name, String password)
>>
>> Question : how I must realize the link between the two objects, for
>> example
>> for the "insertPerson" DAO, I must firstly to insert the liste of
>> accounts
>> next the person or inside of the method "insertPerson" DAO I call
>> "insertAccount" DAO to get the list of accounts ?
>> In the same way for the "getAllPerson" which return a Person object.
>>
>> Generally how to implement the composite objects with Ibatis.
>>
>> Regards;
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6864096
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by soussou97 <db...@yahoo.fr>.
Hi Larry;

For insert DAO : if I realize firstly the parent (Person) DAO, my list of
Account will be empty (next I must fill it) ?

regards;


Larry Meadors-2 wrote:
> 
> For fetching from the database:
> 
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem
> 
> For writing, you just have to do the parent, then the children in order.
> 
> Larry
> 
> 
> On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>>
>> Hi;
>>
>> I have a two java Beans as follows :
>>
>> public class Person implements serializable {
>>     private Name name;
>>     private String key;
>>     private List account = new ArrayList();
>>
>>
>>     public String getKey() {
>>         return key;
>>     }
>>     private void setKey(String key) {
>>         this.key=key;
>>     }
>>        public Name getName() {
>>         return name;
>>     }
>>     public void setName(Name name) {
>>         this.name = name;
>>     }
>>     public void setAccount(List accounts) {
>>         this.accounts = accounts;
>>   }
>>
>>   public List getAccounts() {
>>         return account;
>>   }
>>     ......
>> }
>>
>> public class Account implements Serializable {
>>
>>   private String username;
>>   private String password;
>>   private String email;
>>   private String firstName;
>>   private String lastName;
>>   private String status;
>>
>>
>>   public String getUsername() {
>>     return username;
>>   }
>>
>>   public void setUsername(String username) {
>>     this.username = username;
>>   }
>>
>>   public String getPassword() {
>>     return password;
>>   }
>>
>>   public void setPassword(String password) {
>>     this.password = password;
>>   }
>>
>>   public String getEmail() {
>>     return email;
>>   }
>>
>>   public void setEmail(String email) {
>>     this.email = email;
>>   }
>>
>>   public String getFirstName() {
>>     return firstName;
>>   }
>>
>>   public void setFirstName(String firstName) {
>>     this.firstName = firstName;
>>   }
>>
>>   public String getLastName() {
>>     return lastName;
>>   }
>>
>>   public void setLastName(String lastName) {
>>     this.lastName = lastName;
>>   }
>>
>>   public String getStatus() {
>>     return status;
>>   }
>>
>>   public void setStatus(String status) {
>>     this.status = status;
>>   }
>>
>>  }
>> And I would like to realize the method DAO for creating a new person with
>> its accounts, getting all person into the database with the accounts and
>> updating a person with its accounts.
>> I have the following methodes DAO :
>>
>> insertAccount(Account a)
>> insertPerson (Person p)
>> UpdateAccount(Account a)
>> UpdatePerson(Person p)
>> getAllPerson(String key)
>> getAllAccount(String name, String password)
>>
>> Question : how I must realize the link between the two objects, for
>> example
>> for the "insertPerson" DAO, I must firstly to insert the liste of
>> accounts
>> next the person or inside of the method "insertPerson" DAO I call
>> "insertAccount" DAO to get the list of accounts ?
>> In the same way for the "getAllPerson" which return a Person object.
>>
>> Generally how to implement the composite objects with Ibatis.
>>
>> Regards;
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6857769
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Composite objects

Posted by Larry Meadors <lm...@apache.org>.
For fetching from the database:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem

For writing, you just have to do the parent, then the children in order.

Larry


On 10/17/06, soussou97 <db...@yahoo.fr> wrote:
>
> Hi;
>
> I have a two java Beans as follows :
>
> public class Person implements serializable {
>     private Name name;
>     private String key;
>     private List account = new ArrayList();
>
>
>     public String getKey() {
>         return key;
>     }
>     private void setKey(String key) {
>         this.key=key;
>     }
>        public Name getName() {
>         return name;
>     }
>     public void setName(Name name) {
>         this.name = name;
>     }
>     public void setAccount(List accounts) {
>         this.accounts = accounts;
>   }
>
>   public List getAccounts() {
>         return account;
>   }
>     ......
> }
>
> public class Account implements Serializable {
>
>   private String username;
>   private String password;
>   private String email;
>   private String firstName;
>   private String lastName;
>   private String status;
>
>
>   public String getUsername() {
>     return username;
>   }
>
>   public void setUsername(String username) {
>     this.username = username;
>   }
>
>   public String getPassword() {
>     return password;
>   }
>
>   public void setPassword(String password) {
>     this.password = password;
>   }
>
>   public String getEmail() {
>     return email;
>   }
>
>   public void setEmail(String email) {
>     this.email = email;
>   }
>
>   public String getFirstName() {
>     return firstName;
>   }
>
>   public void setFirstName(String firstName) {
>     this.firstName = firstName;
>   }
>
>   public String getLastName() {
>     return lastName;
>   }
>
>   public void setLastName(String lastName) {
>     this.lastName = lastName;
>   }
>
>   public String getStatus() {
>     return status;
>   }
>
>   public void setStatus(String status) {
>     this.status = status;
>   }
>
>  }
> And I would like to realize the method DAO for creating a new person with
> its accounts, getting all person into the database with the accounts and
> updating a person with its accounts.
> I have the following methodes DAO :
>
> insertAccount(Account a)
> insertPerson (Person p)
> UpdateAccount(Account a)
> UpdatePerson(Person p)
> getAllPerson(String key)
> getAllAccount(String name, String password)
>
> Question : how I must realize the link between the two objects, for example
> for the "insertPerson" DAO, I must firstly to insert the liste of accounts
> next the person or inside of the method "insertPerson" DAO I call
> "insertAccount" DAO to get the list of accounts ?
> In the same way for the "getAllPerson" which return a Person object.
>
> Generally how to implement the composite objects with Ibatis.
>
> Regards;
>
> --
> View this message in context: http://www.nabble.com/Composite-objects-tf2460146.html#a6857135
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>