#191 Non-Standard getter/setter names and deep-mapping issue

Dozer v5.2
closed
7
2015-03-26
2009-05-04
spointk
No

When using the following mapping, the objects are mapped properly, but an exception is thrown.

The getter / setter methods in the objects to map don't use standard naming. If the fieldname is explicitly excluded (see below), everything works fine.

Is that the expectd behaviour or a bug?

I'm looking forward to reading your replies ;-)

Kind regards

S.K.

<mapping stop-on-errors="false">
<class-a>dataObjects.DeepMappingTest</class-a>
<class-b>dataObjects.sampleBO</class-b>

<field>
<a>theStringValue.theValue</a>
<b>theStringValue</b>
</field>
<!--
<field-exclude>
<a>theStringValue</a>
<b>theStringValue</b>
</field-exclude>
-->
</mapping>

Field mapping error -->
MapId: null
Type: null
Source parent class: dataObjects.sampleBO
Source field name: theStringValue
Source field type: class java.lang.String
Source field value: String for testing purpose...
Dest parent class: dataObjects.DeepMappingTest
Dest field name: theStringValue
Dest field type: dataObjects.WrapperObject
java.lang.IllegalArgumentException: argument type mismatch
.
.
.

Discussion

  • spointk

    spointk - 2009-05-04

    Sources reproducing the issue

     
  • spointk

    spointk - 2009-05-04
    • priority: 5 --> 7
     
  • Vadim Shaigorodskiy

    By default, Dozer builds mappings between fields with the same name. In your example, dozer builds mapings:
    1. between theStringValue.theValue and theStringValue
    2. between theStringValue and theStringValue of the DeepMappingTest object.

    The second mapping cause an exception, because field types do not match. You need set wildcard="false" to your mapping and it will work fine, but in this case you'll need ti write mappings between all the rest fields by yourself. Dozer won't build mapping between attributes with the same name.

     
  • Vadim Shaigorodskiy

    I've added more detailed message, when argument type mismatch occurs.

     
  • dmitry (lv)

    dmitry (lv) - 2009-12-20

    closing this issue. this was an intended behaviour. correction was made to source code to make error message look more meaningful.

     
  • dmitry (lv)

    dmitry (lv) - 2009-12-20
    • milestone: 897300 --> Dozer v5.2
    • assigned_to: nobody --> vadeg
    • 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