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.
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);