Menu

#48 in place collection mapping not supported

closed
None
5
2006-09-02
2006-06-09
Brad Davis
No

given the following classes...

class Foo {
private List<Long> categories = null;

public List<Long> getCategories() {
return this.categories;
}

public void setCategories(List<Long> list) {
return this.categories = list;
}
}

class FooPrime {
private List<Long> categories = null;

public List<Long> getCategories() {
if (categories == null) {
categories = new ArrayList<Long>();
}
return this.categories;
}
}

There is no way to map an instance of class FooPrime as
a destination class, because it contains no setter.
However, the design pattern of a list that can't be
replaced, but must be modfied in place is common in
both Hibernate and Jaxb generated classes.

Discussion

  • Matt Tierney

    Matt Tierney - 2006-08-12
    • assigned_to: nobody --> mhtierney
    • status: open --> pending
     
  • Matt Tierney

    Matt Tierney - 2006-08-12

    Logged In: YES
    user_id=1236069

    I fixed this issue via Field.setAccessible().
    field = bean.getDeclaredField(fieldName);
    //Allow access to private instance var's that dont
    have public setter. "is-accessible=true" must be
    explicitly specified in
    //mapping file to allow this access. setAccessible
    indicates intent to bypass field protections.
    field.setAccessible(isAccessible);

     
  • Matt Tierney

    Matt Tierney - 2006-09-02
    • status: pending --> closed
     

Log in to post a comment.