| Moxy JPA+JAXB mapping issue with list unwrapping [message #938979] |
Wed, 10 October 2012 06:15  |
Mark Jones Messages: 5 Registered: October 2012 |
Junior Member |
|
|
Hi I am struggling to create a mapping from my JPA object to my targeted xml schema.
My main class structure is as follows for brevity -:
Project {
private Set<ProjectAbstract> projectAbstracts = new HashSet<ProjectAbstract>(0);
}
ProjectAbstract {
private String abstract;
private String fooAttribute;
}
I desire this output.
<project>
<abstract fooAttribute="foo">abstract text</abstract>
<abstract fooAttribute="foo">abstract text</abstract>
</project>
I have tried XMLAdaptor, XmlPath and numerous approaches but I cannot unwrap the set and end up with (or similar) -:
<project>
<ProjectAbstracts>
<abstract fooAttribute="foo">abstract text</abstract>
<abstract fooAttribute="foo">abstract text</abstract>
</ProjectAbstracts>
</project>
I have literally hundreds of classes so creating a full set of JAXB bindings and mapping code really isn't much of an option!
Maybe my XMLadaptor is incorrect but I cant see how to make it accept Collections and work in the way I desire.
Regards
EDIT: I have switched to the latest Moxy to try and achieve this
[Updated on: Wed, 10 October 2012 06:16] Report message to a moderator
|
|
|
|
|
|
|
| Re: Moxy JPA+JAXB mapping issue with list unwrapping [message #940593 is a reply to message #940289] |
Thu, 11 October 2012 15:50  |
Mark Jones Messages: 5 Registered: October 2012 |
Junior Member |
|
|
Hi thanks again. This worked on the test case but failed on my code.
Some sleuthing revealed this was down to JPA bytecode manipulation as I am using lazy fetching and the OSIV pattern for this read only part of the code. So far even during fairly complex documents the only error point was at -:
@XmlValue private String ISO639LangCode;
As have hundreds of entities and countless thousands of JPA fields so I am trying to keep the annotations to a minimum otherwise I will be chasing small xml output bugs for the rest of my life.
Is there some way around this?
Could JPA or JAXB be forced into a different mode for example?
Regards
EDIT: I have solved this annotating on the property works.
Thanks again.
[Updated on: Thu, 11 October 2012 16:24] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01697 seconds