[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-user
Subject: Commons dbutils - question on populating a bean that has a property that is a list of primitives
From: "Philip, Anil - Kansas City, MO" <anil.philip () kcc ! usda ! gov>
Date: 2009-07-16 17:46:19
Message-ID: 22ED5A9EB260F2488FC761C5602669740145BBF9 () mokansascis309 ! agcentral ! one ! usda ! gov
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic