Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] [MOXy] overriding mapped xpaths in inheritance hierarchy

Hi Polly,

I apologize for the delay in responding, I'm looking into your issue now.  If you define the mapping on both the parent and child descriptors, then what you are going to see when you marshal and instance of Child to XML is something like the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <root type="child">
       <foo>B</foo>
       <bar>B</bar>
       <field2>C</field2>
    </root>

I have entered a bug for this issue, can you check out the entry below and confirm this is the use case you would like supported?

    https://bugs.eclipse.org/299691

-Blaise

polly.c.chang wrote:
Hi,

Does anyone know what I should expect EclipseLink to do in the scenario
below?

Thanks!
--Polly


polly.c.chang wrote:
  
Hi,

Given these classes:

public class Parent {
    String field1;
}

public class Child extends Parent {
    String field2;
}

I know that if I *don't* set up a class mapping for "Parent", I can create
a class mapping for "Child" that defines attribute mappings for both
"field1" (the attribute belonging to the Parent) and "field2" (the
attribute belonging to the Child).

Now what if I:

1.  Set up a class mapping for "Parent" that has an attribute mapping for
"field1" set to an xpath of "foo/text()"
2.  Set up a class mapping for "Child" with an "inheritance policy" for
"Parent", and define attribute mappings for "field1" and "field2".  The
xpath for "field1" is "bar/text()".

What happens in that case?  Does the Child's mapping for "field1" override
the mapping defined in Parent?  Or is it ignored?  Or does this cause an
exception?  

I could probably guess by doing some trial and error, but I'd like to know
what the expected behavior is (especially since there are multiple
versions of EclipseLink now :).

Thanks!
--Polly

    
  

Back to the top