#97 Copy Reference mapping instructions ignored for subclasses

closed
None
5
2007-07-15
2007-05-30
Brad Harvey
No

Hi,

In dozer 3.4, copy-by-reference directives in mapping files are ignored unless the source object is the same class as specified in the mapping - subclasses, anonymous subclasses, dynamic proxies etc will not work.

It does appear to work in 3.3.1.

I'll attach some unit tests illustrating the problem.

Using a simple mapping with one field name change and one copy by reference specified:

<mapping>
<class-a>example.TestA</class-a>
<class-b>example.TestB</class-b>
<field>
<a>oneA</a>
<b>oneB</b>
</field>
<field copy-by-reference="true">
<a>testReference</a>
<b>testReference</b>
</field>
</mapping>

SubclassReferenceTest

#testBase passes, just a sanity check
#testSubclassSource passes - the oneA <-> oneB mapping is still detected for an anonymous subclass of TestA.
#testReference passes - the copy-by-reference is fine for TestA itself.
#testReferenceSubclassSource fails - net.sf.dozer.util.mapping.MappingException: java.lang.InstantiationException: example.TestReference

example.TestReference has a private constructor to force an error if copy by reference isn't used.

I'm also completely unable to make the global configuration for copy-by-reference work, the GlobalReferenceTest illustrates this. This does not appear to be new to dozer 3.4, and may well be me doing something wrong - please point it out!

Regards,
Brad.

Discussion

  • Brad Harvey

    Brad Harvey - 2007-05-30

    Failing unit tests

     
  • Brad Harvey

    Brad Harvey - 2007-05-30

    Logged In: YES
    user_id=1804484
    Originator: YES

    Some further info - testReferenceSubclassSource passes under jdk1.4 but not jdk1.5.

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-30

    Logged In: YES
    user_id=550744
    Originator: NO

    This sounds like it is related to:

    [ dozer-Bugs-1728385 ] Global custom converters missing in default ClassMap

    This will be fixed in the next release.

    Franz

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-30
    • assigned_to: nobody --> fgarsombke
     
  • Franz Garsombke

    Franz Garsombke - 2007-06-03
    • status: open --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2007-06-03

    Logged In: YES
    user_id=550744
    Originator: NO

    fixed in 3.x branch.

     
  • Matt Tierney

    Matt Tierney - 2007-07-15
    • status: pending --> 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