ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soussou97 <dbousse...@yahoo.fr>
Subject Re: Composite objects
Date Thu, 19 Oct 2006 08:44:06 GMT

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 <dboussebha@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 <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.
>> >>
>> >>
>> >
>> >
>>
>> --
>> 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.


Mime
View raw message