ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xianwinwin <xianwin...@gmail.com>
Subject how to return a LIST and populate it in an object
Date Sun, 13 Jul 2008 17:22:22 GMT

I have a query that returns from the db an arrayList of class CarBean:

carID, model, color, rentUserID, fname, lname, dateRentStart, dateRentEnd

The query is with reference to a particular car that N people (rentUserID)
rented and the user (the system user) wish to know how many rentals were
made for this carID.

I wish to populate the result into ONE class name CarRental which looks like

private Car; //model
private List<RentUser> rentals; //all info relating to rentUser

so, my question is this, using iBatis is there a way to have a LIST of
RentUser and a Car object so the CarRental object will have the Car object
and a LIST of rentUser. 

right now, I'm doing this

Iterator<CarBean> itr = list.iterator();
CarRental carRental = new CarRental();
List rentals = new ArrayList();
while (itr.hasNext())
    CarBean cb = itr.next();
    //for the list of users:
   User u = new User();  

* please consider a more complicated query that the end result of ONE object
should have X arrayList and other M objects in it

thank you!
View this message in context: http://www.nabble.com/how-to-return-a-LIST-and-populate-it-in-an-object-tp18431512p18431512.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

View raw message