#73 bi-directionnal mapping with sets & subclasse

closed
None
5
2007-05-21
2007-02-21
roua dec
No

Since the recursivity issue has been fixed in 3.0 I stumbled on another issue with :

class ParentA
class A extends ParentA {
Set<B> subs
}

class B {
owner A
}

and their corresponding *Prime classes to map to.

mappings are :
<mapping wildcard="true">
<class-a>A</class-a>
<class-b>APrime</class-b>
<field>
<a>subs</a>
<b>subs</b>
<a-hint>B</a-hint>
<b-hint>BPrime</b-hint>
</field>
</mapping>
<mapping wildcard="true">
<class-a>ParentA</class-a>
<class-b>ParentAPrime</class-b>
</mapping>
<mapping wildcard="true">
<class-a>B</class-a>
<class-b>BPrime</class-b>
<field>
<a>owner </a>
<b>owner </b>
<a-hint>A</a-hint>
<b-hint>APrime</b-hint>
</field>
</mapping>

When dozer does the mapping it sort of mess up the references in this way :

before mapping (the @ denote the java object id) we have:
ParentA@1 {
subs {
B@2 {
owner ParentA@1 { recursion correct from here... }
}
}
}

after mapping we get:
ParentAPrime@3 {
subs {
BPrime@4 {
owner ParentAPrime@5 {
subs {
BPrime@4 {
owner ParentAPrime@5 { recursion correct from here.... }
}
}
}
}
}

I was expecting the owner to be ParentAPrime@3 and not ParentAPrime@5 which is a different instance.

Discussion

  • roua dec

    roua dec - 2007-02-21

    unit test, build and runned with eclipse but should work without it

     
  • pluimpje

    pluimpje - 2007-05-15

    Logged In: YES
    user_id=1792692
    Originator: NO

    probable sollution:

    in MappingProcessor.java

    a few lines below the following comment
    // 1596766 - Recursive object mapping issue. Prevent recursive mapping infinite loop

    changed
    if (value.getClass().equals(destFieldType)) {
    with
    if(destFieldType.isAssignableFrom(value.getClass())){

    This resolves the problem in my test case.
    reason is that the destFieldType was of the type of the superClass and thus the equals did give the wanted result.

     
  • Franz Garsombke

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

    Franz Garsombke - 2007-05-17

    Logged In: YES
    user_id=550744
    Originator: NO

    I will get this into the next release.

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-18

    Logged In: YES
    user_id=550744
    Originator: NO

    fixed in 3.x branch

     
  • Franz Garsombke

    Franz Garsombke - 2007-05-18
    • status: open --> pending
     
  • Franz Garsombke

    Franz Garsombke - 2007-05-21
    • 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