Do you need the relationship to be bi-directional in the schema as well ? If not, you can eliminate one direction by adding @XmlTranisent annotation, like this:
@XmlTransient
@ManyToOne
private Categoria categoria;
----- Original Message -----
From: Fernando Parisotto
To: users_at_jax-ws.dev.java.net
Sent: Monday, October 30, 2006 10:18 PM
Subject: Circular relationship problems with jaxb and jax-ws
Hy every one,
I have 2 classes,
-------------------------------------------------------------------
package net.uniplac.tcc.segurancaws.model;
// imports...
public class Categoria implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
@Column(nullable=false, unique = true)
private String nome;
private String unidade;
@OneToMany(mappedBy = "categoria")
private Set<Produto> produtos;
// gets and sets
}
---------------------------------------------------------------
and
---------------------------------------------------------------
package net.uniplac.tcc.segurancaws.model;
public class Produto implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY )
private Integer id;
private String nome;
private Double precoUnitario;
private int qdtEstoque;
@ManyToOne
private Categoria categoria;
// gets and sets
}
And I have some serios problems to expose this classes into a Web Services.
I have this exceptions:
javax.xml.soap.SOAPException: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: Mogno -> Door-> Mogno]
java.lang.RuntimeException: javax.xml.soap.SOAPException: javax.xml.soap.SOAPException : javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: Mogno -> Door-> Mogno]
What can I do to avoid this circular relation erros on marshal my object graph?
Please help, thanks for all.
--
Fernando Luiz Parisotto