Witam posiadam trzy klasy encji

package pl.luppo.ztz.model;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "product", propOrder = {
    "category",
    "manufacturer",
    "price",
    "purchasePositions"
})
@Entity
@NamedQueries({
    @NamedQuery(name = Product.ALL, query = "SELECT p FROM Product p  "),
    @NamedQuery(name = Product.TOTAL, query = "SELECT COUNT(p) FROM Product p")})
public class Product extends AbstractEntity implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public final static String ALL = "PRODUCT_ALL";
    public final static String TOTAL = "PRODUCT_TOTAL";

    private Double price;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "MANUFACTURER_ID")
    private Manufacturer manufacturer;
//  @ManyToMany(mappedBy="products")

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CATEGOTY_ID")
    private Category category;
    @OneToMany(mappedBy="product")
    @XmlElement(nillable = true)
    private List<PurchasePosition> purchasePositions;

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Manufacturer getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(Manufacturer manufacturer) {
        this.manufacturer = manufacturer;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<PurchasePosition> getPurchasePositions() {
        return purchasePositions;
    }

    public void setPurchasePositions(List<PurchasePosition> purchasePositions) {
        this.purchasePositions = purchasePositions;
    }

}

```java
package pl.luppo.ztz.model;

import java.util.List;

import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "category", propOrder = { "products" })
@Entity
@NamedQueries({ @NamedQuery(name = Category.ALL, query = "SELECT c FROM Category c  "),
        @NamedQuery(name = Category.TOTAL, query = "SELECT COUNT(c) FROM Category c") })
public class Category extends AbstractEntity {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    public final static String ALL = "CATEGORY_ALL";
    public final static String TOTAL = "CATEGORY_TOTAL";
    @XmlElement(nillable = true)
    @OneToMany(mappedBy = "category")
    private List<Product> products;

    public List<Product> getProducts() {
        return products;
    }

    public void setProducts(List<Product> products) {
        this.products = products;
    }

}
package pl.luppo.ztz.model;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "purchasePosition", propOrder = { "count", "product", "purchase" })
@Entity
public class PurchasePosition extends AbstractEntity {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private int count = 1;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PRODUCT_ID")
    private Product product;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "PURCHASE_ID")
    private Purchase purchase;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Purchase getPurchase() {
        return purchase;
    }

    public void setPurchase(Purchase purchase) {
        this.purchase = purchase;
    }

}

Gdy przesyłam listę obiektów PurchasePosition bez uzupełnionego obiektu produkt (czyli sam obiekt PurchasePosition z id) to wszystko jest dobrze ale gdy tą liste uzupełnię o produkty to mam błąd


ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Industry].[Faces Servlet]] (http-localhost-127.0.0.1-8080-6) Servlet.service() for servlet Faces Servlet threw exception: com.sun.istack.SAXException2: A cycle is detected in the object graph. This will cause infinitely deep XML: [email protected] -> [email protected] -> [email protected]

Wyczytałem że pomaga adnotacja

@XmlAccessorType(XmlAccessType.FIELD)

ale ja już mam ją w swoich encjach. Przesyłanie listy jest za pomocą

public void sendToWS(){
         IndustryWSImplService industryService = new IndustryWSImplService();
            IndustryWS hello = industryService.getIndustryWSImplPort();

            System.out.println("***********************************************************");
            hello.purchaseWS(purchase);
            hello.purchasePositions(initPurchasePositions);
    }

Jeszcze raz podkreślę że jeśli initPurchasePositions zawiera same obiekty PurchasePositions bez produktów wszystko działa poprawnie.

Proszę o pomoc jakich adnotacji użyć aby Parent->child był dobrze mapowany do XML

Z góry dziękuję za pomoc