Announcement Announcement Module
Collapse
No announcement yet.
Having Problems with BeanUtils.. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    Has anyone seen this problem? Or do the hierarchies need to match exactly ? Would using converters be the way to go for these kind of conversions?

    Comment

    Working...
    X