Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » How can I get the child entitites on a XML marshalling using @XmlID and @XmlIDREF annotations. I onl
How can I get the child entitites on a XML marshalling using @XmlID and @XmlIDREF annotations. I onl [message #730580] Wed, 28 September 2011 16:20
Andr is currently offline AndrFriend
Messages: 2
Registered: September 2011
Junior Member
Hello all,

I want to generate an XML file of an object tree with 1:N relashionship. I am using the @XmlID and @XmlIDREF annotations.
The entity "construtora" has N "empreendimentos" entitites related.

The root class is :

class ConstrutoraImpl {
  private long id;
  String nome;  
  String contato;  
  String telefone;
  private List<EmpreendimentoImpl> empreendimentos;

class EmpreeendimentoImpl {
  private long id: 
  String nome;
  String endereco;

  private ConstrutoraImpl construtora;

The java code to generate the XML file is:

JAXBContext context = (JAXBContext) JAXBContext.newInstance(new Class[]{ConstrutoraImpl.class, EmpreendimentoImpl.class});
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(construtora, System.out);

The resulting XML file is:
<?xml version="1.0" encoding="UTF-8"?>
   <empreendimentos>74 75</empreendimentos>

The "empreendimentos" child entities are missing. How can I generate a XML with all the child entitites and the root entity?

All the Best,
André Moutinho
Previous Topic:pingsql
Next Topic:How to use @XmlID and @XmlIDREF annotations on a entity defined by an interface
Goto Forum:

Current Time: Tue Mar 20 02:33:27 GMT 2018

Powered by FUDForum. Page generated in 0.03448 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software