ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Composite objects
Date Tue, 17 Oct 2006 15:14:44 GMT
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 <dboussebha@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.
>
>

Mime
View raw message