-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate CascadeType.ALL
PostPosted: Tue Sep 15, 2009 3:10 am 
Newbie

Joined: Thu Aug 27, 2009 2:24 am
Posts: 3
Location: Kassel, Germany
Hallo zusammen,

ich hab ein kleines Problem mit dem cascade in der Annotation @OneToMany.
ich habe eine Manufacturer welches Product beinhalt. Wenn ich jedoch nun ein ManufacturDO persistiere und anschließend Product hinzufüge, kann ich wenn der CascadeTyp auf ALL steht das wunderbar machen, wenn ich ihn wie unten beschrieben einstelle, funktioniert es nicht dann bekommt das Product so keine ID und dann knallt es bei den Tests.
Ich hab auch schon überlegt ob es an der Konfiguration meiner HSQLDB liegt aber ich wüsst net wo ich da ansetzen sollte.
Vielleicht kann mir das jemand mal genau erklären wie das mit dem CascadeTyp sich genau verhält?

grüße
keks

Hier die Manufacture Klasse:

Code:
@Entity
@Table(name = "T_SA_MANUFACTURER")
@DiscriminatorValue("MANUFACTURER")
@PrimaryKeyJoinColumn(name = "SAID")
public class ManufacturerDO extends SearchableDO<ManufacturerDTO> {

    /**
     *
     */
    private static final long serialVersionUID = -1844189824276668613L;
    private List<ProductDO> products;

    @OneToMany(mappedBy = "manufacturer", fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH, CascadeType.MERGE,
            CascadeType.PERSIST })
    public List<ProductDO> getProducts() {
        if (products == null) {
            products = new ArrayList<ProductDO>();
        }
        return products;
    }

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


Und die Produkt Klasse:

Code:
@Entity
@Table(name = "T_SA_PRODUCT")
@DiscriminatorValue("PRODUCT")
@PrimaryKeyJoinColumn(name = "SAID")
// SAID = SearchableDO.id
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, include = "non-lazy")
public class ProductDO extends SearchableDO<ProductDTO> {
    private static final Logger LOG = Logger.getLogger(ProductDO.class);

    private ManufacturerDO manufacturer;

    private ProductInfoDO productInfos;

    private ProductQuantityDO quantity;

    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "manufacturer_id")
    public ManufacturerDO getManufacturer() {
        return manufacturer;
    }

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

    public ProductInfoDO getProductInfos() {
        return productInfos;
    }

    public void setProductInfos(final ProductInfoDO productInfos) {
        this.productInfos = productInfos;
    }

    public ProductQuantityDO getQuantity() {
        return quantity;
    }

    public void setQuantity(final ProductQuantityDO quantity) {
        this.quantity = quantity;
    }

_________________
nicht ist wahr, alles ist erlaubt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.