Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-dev] How to use @XmlID and @XmlIDREF annotations on a entity defined by an interface?

Hi André,

You can use the @XmlElement annotation to specify the concrete implementation class that is backing the interface:

    import java.util.List;
    import javax.xml.bind.annotation.*;

    class ConstrutoraImpl implements Construtora {
        @XmlID
        private long id;

        String nome;
        String contato;
        String telefone;

        @XmlIDREF
        @XmlList
        @XmlElement(type=EmpreendimentoImpl.class)
        private List<Empreendimento> empreendimentos;

    }


For More Information
-Blaise

André Moutinho wrote:
Hello all

I have the following entities:


class ConstrutoraImpl implements Construtora {
  @XmlID
  private long id;

  String nome;
  String contato;
  String telefone;

  @XmlIDREF
  @XmlList
  private List<EmpreendimentoImpl> empreendimentos;
}


class EmpreeendimentoImpl  implements Empreendimento {
  @XmlID
  private long id:
  String nome;
  String endereco;

  private ConstrutoraImpl construtora;
}


When I execute the marshalling process I get the following exception:

javax.xml.bind.JAXBException:
Exception Description: Invalid XmlIDREF on property [empreendimentos].
 Class [br.inpe.extfv.entity.api.Empreendimento] is required to have a
property annotated with XmlID.
 - with linked exception:
[Exception [EclipseLink-50017] (Eclipse Persistence Services -
2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.JAXBException
Exception Description: Invalid XmlIDREF on property [empreendimentos].
 Class [br.inpe.extfv.entity.api.Empreendimento] is required to have a
property annotated with XmlID.]
	at org.eclipse.persistence.jaxb.JAXBContext$TypeMappingInfoInput.createContextState(JAXBContext.java:825)
	at org.eclipse.persistence.jaxb.JAXBContext.<init>(JAXBContext.java:136)

	at org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(JAXBContextFactory.java:142)



How to use @XmlID and @XmlIDREF annotations on a entity defined by an
interface. Is there any kind of proxy definition on this case?

All the Best,
_______________________________________________
eclipselink-dev mailing list
eclipselink-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-dev
  

Back to the top