-
Nov 16th, 2012, 01:15 PM
#1
Having Problems with BeanUtils..
I am trying to use BeanUtils(Spring 3.0.5) to copy properties from one hierarchy to another. Following is what I use BeanUtils.copyProperties(source, dest);
My source is as follows
School is a class which has a collection of ClassPeriodType . ClassPeriodType is derived from PeriodType and adds its own properties to it as well.
PeriodType (has startDate,endDate,reason)
||
ClassPeriodType (it derives from the PmabPeriodType
public class School{
private List<ClassPeriodType> periods;
}
My dest is as follows
Company as a class which has a collection of PlanPeriods .
public class Company
{
private List <PlanPeriod> periods;
// getters and setters and other properties omitted for brevity
}
PlanPeriod has startDate,endDate as its properties.(no hierarchy here) .
//Code snippet
Company dest=new Company();
School school =new School();
school.addPeriods (// new set of ClassPeriodType periods added)
// What i am expecting here is to have the Company with a list of PlanPeriod types when i do this..
BeanUtils.copyProperties(source, dest);
instead what i am getting is Company -> List<ClassPeriodType> periods instead of Company-> List<PlanPeriod>.
The reflection is not happening throughout both the source and destination hierarchy . How do i achieve this ?
Cheers
Vaidya
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules