commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philip, Anil - Kansas City, MO" <anil.phi...@kcc.usda.gov>
Subject Commons dbutils - question on populating a bean that has a property that is a list of primitives
Date Thu, 16 Jul 2009 17:46:19 GMT
Hi,
Can dbutils populate a bean that has a property that is a list of
primitives? (one-to-many relationships)
I looked at the source code but it wasn't clear that it can because a
new bean is created for each row in the result set. BeanProcessor
methods createBean() and processColumn().
(http://svn.apache.org/viewvc/commons/proper/dbutils/tags/DBUTILS_1_2/sr
c/java/org/apache/commons/dbutils/)
For example: 
class Department has property ArrayList<String> employee_name
select department.department_location, employee.employee_name from
department JOIN employee ON  department.id = employee.dept_id;
So we get a result set like:
'Kansas City',  'John'
'Kansas City',  'Elisabeth'
'Kansas City',  'David'
'Bangalore',  'Kiran'

It seems that createBean() creates a new Department instance for each
row, rather than retrieve that instance and add the list of other names
to it. 
thanks,
Anil 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message