From e83ea07a68440a9d435c5e5a65115f1242ad6d49 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Fri, 16 Oct 2015 13:14:25 +0200 Subject: [PATCH] =?utf8?q?added=20missing=20cascade=20type,=20at=20least?= =?utf8?q?=20MERGE=20Signed-off-by:Roland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/org/mxchange/jshopcore/model/basket/items/BasketItem.java | 3 ++- src/org/mxchange/jshopcore/model/category/ProductCategory.java | 3 ++- src/org/mxchange/jshopcore/model/customer/ShopCustomer.java | 3 ++- src/org/mxchange/jshopcore/model/order/ShopOrder.java | 3 ++- src/org/mxchange/jshopcore/model/order/items/OrderItem.java | 3 ++- src/org/mxchange/jshopcore/model/product/GenericProduct.java | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java b/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java index 83775c3..57a2c43 100644 --- a/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java +++ b/src/org/mxchange/jshopcore/model/basket/items/BasketItem.java @@ -17,6 +17,7 @@ package org.mxchange.jshopcore.model.basket.items; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -69,7 +70,7 @@ public class BasketItem extends BaseItem implements AddableBasketItem { * Product instance */ @JoinColumn (name = "product_id", updatable = false) - @OneToOne (targetEntity = GenericProduct.class) + @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.MERGE) private Product itemProduct; /** diff --git a/src/org/mxchange/jshopcore/model/category/ProductCategory.java b/src/org/mxchange/jshopcore/model/category/ProductCategory.java index c5b055f..003da6b 100644 --- a/src/org/mxchange/jshopcore/model/category/ProductCategory.java +++ b/src/org/mxchange/jshopcore/model/category/ProductCategory.java @@ -18,6 +18,7 @@ package org.mxchange.jshopcore.model.category; import java.util.Objects; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -53,7 +54,7 @@ public class ProductCategory implements Category, Comparable { * Parent category */ @JoinColumn (name = "parent_id") - @OneToOne (targetEntity = ProductCategory.class) + @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.MERGE) private Category parentCategory; /** diff --git a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java index b52754b..2db4c22 100644 --- a/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java +++ b/src/org/mxchange/jshopcore/model/customer/ShopCustomer.java @@ -18,6 +18,7 @@ package org.mxchange.jshopcore.model.customer; import java.util.Calendar; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -52,7 +53,7 @@ public class ShopCustomer implements Customer { * Id number from "contacts" table */ @JoinColumn (name = "contact_id", nullable = false, updatable = false, unique = true) - @OneToOne (targetEntity = UserContact.class, optional = false) + @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false) private Contact contact; /** diff --git a/src/org/mxchange/jshopcore/model/order/ShopOrder.java b/src/org/mxchange/jshopcore/model/order/ShopOrder.java index c0757c4..66b75e0 100644 --- a/src/org/mxchange/jshopcore/model/order/ShopOrder.java +++ b/src/org/mxchange/jshopcore/model/order/ShopOrder.java @@ -19,6 +19,7 @@ package org.mxchange.jshopcore.model.order; import java.util.Calendar; import java.util.List; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -67,7 +68,7 @@ public class ShopOrder implements Orderable { * Customer instance */ @JoinColumn (name = "customer_id", nullable = false, updatable = false) - @OneToOne (targetEntity = ShopCustomer.class, optional = false) + @OneToOne (targetEntity = ShopCustomer.class, cascade = CascadeType.MERGE, optional = false) private Customer customer; /** diff --git a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java index c1783fb..e07bbf7 100644 --- a/src/org/mxchange/jshopcore/model/order/items/OrderItem.java +++ b/src/org/mxchange/jshopcore/model/order/items/OrderItem.java @@ -17,6 +17,7 @@ package org.mxchange.jshopcore.model.order.items; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -70,7 +71,7 @@ public class OrderItem extends BaseItem implements AddableBasketItem { * Product instance */ @JoinColumn (name = "product_id", updatable = false) - @OneToOne (targetEntity = GenericProduct.class) + @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.MERGE) private Product product; /** diff --git a/src/org/mxchange/jshopcore/model/product/GenericProduct.java b/src/org/mxchange/jshopcore/model/product/GenericProduct.java index a2daad1..45bca21 100644 --- a/src/org/mxchange/jshopcore/model/product/GenericProduct.java +++ b/src/org/mxchange/jshopcore/model/product/GenericProduct.java @@ -18,6 +18,7 @@ package org.mxchange.jshopcore.model.product; import java.util.Objects; import javax.persistence.Basic; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -54,7 +55,7 @@ public class GenericProduct implements Product, Comparable { * Product productCategory */ @JoinColumn (name = "category_id", nullable = false, updatable = false) - @OneToOne (targetEntity = ProductCategory.class, optional = false) + @OneToOne (targetEntity = ProductCategory.class, cascade = CascadeType.MERGE, optional = false) private Category productCategory; /** -- 2.39.5