#32 exclude-field doesn't work on an indexed property

closed
None
5
2006-01-17
2006-01-13
No

If you have an indexed property in your class, and a
getter for one element of it, but not a getter for the
whole array/collection, it is not possible to exclude
it with <exclude-field>.

Instead, it fails with this error:

net.sf.dozer.util.mapping.MappingException: Unable to
determine read method for field: emailAdres class:
class nl.wehkamp.trc.services.klant.KlantVO

The case is: the source class contains the methods

getEmailAdres(int i)
getEmailAdressen()

(It's dutch, hence the weird spelling, but
emailAdressen is the plural of emailAdres)
This source class is wrong in JavaBeans terms, the
first getter should have been named

getEmailAdressen(int i)

But it's a legacy class and I can't change it. So I
want to exclude the field emailAdres, but that gives
the above exception.

It seems that even if I ignore a field, it still
requires a (non-indexed) read method for it.

Discussion

  • Franz Garsombke

    Franz Garsombke - 2006-01-13
    • assigned_to: nobody --> fgarsombke
     
  • Franz Garsombke

    Franz Garsombke - 2006-01-13

    Logged In: YES
    user_id=550744

    I will verify and fix this for the 2.0 release this week.

     
  • Franz Garsombke

    Franz Garsombke - 2006-01-13

    Logged In: YES
    user_id=550744

    This is fixed in the v20 branch which will be released in a
    couple days. To fix in v15 branch modify
    MappingProccessor.java around line 234 - 245 with this code.
    I would normally patch from v15 to v20 but we are so close
    to the release.

    // Iterate through destination object and get
    destination field values
    for (int i = 0; i < fieldMaps.size(); i++) {
    FieldMap fieldMapping = (FieldMap) fieldMaps.get(i);
    Object sourceFieldValue = null;
    try {
    // these maps are special cases which do not fall
    under what we are looking for
    if ((!isGenericFieldMap(fieldMapping) ||
    !(fieldMapping instanceof ExcludeFieldMap))
    && !(fieldMapping instanceof MapFieldMap)) {
    // then do no validation
    } else {
    sourceFieldValue =
    fieldMapping.getSrcFieldValue(sourceObj);
    // check for super class names

     
  • Franz Garsombke

    Franz Garsombke - 2006-01-13
    • status: open --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2006-01-13
    • status: pending --> open
     
  • Franz Garsombke

    Franz Garsombke - 2006-01-13

    Logged In: YES
    user_id=550744

    This should be the actual code:

    // Iterate through destination object and get
    destination field values
    for (int i = 0; i < fieldMaps.size(); i++) {
    FieldMap fieldMapping = (FieldMap) fieldMaps.get(i);
    Object sourceFieldValue = null;
    try {
    // these maps are special cases which do not fall
    under what we are looking for
    if ((!isGenericFieldMap(fieldMapping) &&
    !(fieldMapping instanceof MapFieldMap))) {
    // then do no validation
    } else if (fieldMapping instanceof ExcludeFieldMap) {
    // then do no validation
    } else {
    sourceFieldValue =
    fieldMapping.getSrcFieldValue(sourceObj);
    // check for super class names

     
  • Franz Garsombke

    Franz Garsombke - 2006-01-17
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks