[seam-issues] [JBoss JIRA] Commented: (SEAMJCR-21) Properties from parent class should be mapped as well
Simon Gunzenreiner (JIRA)
jira-events at lists.jboss.org
Fri Aug 5 10:39:40 EDT 2011
[ https://issues.jboss.org/browse/SEAMJCR-21?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12619138#comment-12619138 ]
Simon Gunzenreiner commented on SEAMJCR-21:
-------------------------------------------
The following snipped works for me:
in OCMMappingStore.map()
List<Field> fields = new ArrayList<Field>();
addFields(clazz, fields);
with:
void addFields(Class<?> clazz, List<Field> fieldList) {
// Assumption: we also want to persist fields of object which are not themselves persistable
Field[] fields = clazz.getDeclaredFields();
fieldList.addAll(Arrays.asList(fields));
Class<?> supr = clazz.getSuperclass();
if (supr != Object.class) {
// we never want to persist java.lang.Objects
addFields(supr, fieldList);
}
}
> Properties from parent class should be mapped as well
> -----------------------------------------------------
>
> Key: SEAMJCR-21
> URL: https://issues.jboss.org/browse/SEAMJCR-21
> Project: Seam JCR
> Issue Type: Feature Request
> Components: OCM
> Reporter: Simon Gunzenreiner
> Priority: Minor
>
> OCMMappingStore.map() currently does not map inherited fields, due to considering only fields defined on the given class. I suggest to use clazz.getFields() instead of clazz.getDeclaredFields().
> Also, this behaviour is not in-line with the usage of clazz.getMethods(), which takes into account the accessor methods of parent classes (correct behaviour).
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the seam-issues
mailing list