From 3de249807ceddf963ca6cc6be5e059018bf9ce4a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 19 Apr 2020 08:27:51 +0200 Subject: [PATCH] Product-only: - set productEntryUpdated when update business method has finished - detachedProduct is misleading as it is a managed (JPA) instance MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../product/PizzaAdminGenericProductSessionBean.java | 11 +++++++---- .../product/BasePizzaProductEnterpriseBean.java | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/java/org/mxchange/jproduct/model/product/PizzaAdminGenericProductSessionBean.java b/src/java/org/mxchange/jproduct/model/product/PizzaAdminGenericProductSessionBean.java index c82ecd5..3bc68ce 100644 --- a/src/java/org/mxchange/jproduct/model/product/PizzaAdminGenericProductSessionBean.java +++ b/src/java/org/mxchange/jproduct/model/product/PizzaAdminGenericProductSessionBean.java @@ -101,7 +101,7 @@ public class PizzaAdminGenericProductSessionBean extends BasePizzaProductEnterpr } // Set created instance - product.setProductCreated(new Date()); + product.setProductEntryCreated(new Date()); // Persist it this.getEntityManager().persist(product); @@ -134,13 +134,16 @@ public class PizzaAdminGenericProductSessionBean extends BasePizzaProductEnterpr } // Merge data - final Product detachedProduct = this.mergeProductData(product); + final Product managedProduct = this.mergeProductData(product); + + // Set updated instance + managedProduct.setProductEntryUpdated(new Date()); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductData: detachedProduct={1} - EXIT!", this.getClass().getSimpleName(), detachedProduct)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateProductData: managedProduct={1} - EXIT!", this.getClass().getSimpleName(), managedProduct)); //NOI18N // Return it - return detachedProduct; + return managedProduct; } /** diff --git a/src/java/org/mxchange/pizzaapplication/enterprise/product/BasePizzaProductEnterpriseBean.java b/src/java/org/mxchange/pizzaapplication/enterprise/product/BasePizzaProductEnterpriseBean.java index dbb93bc..def6fa5 100644 --- a/src/java/org/mxchange/pizzaapplication/enterprise/product/BasePizzaProductEnterpriseBean.java +++ b/src/java/org/mxchange/pizzaapplication/enterprise/product/BasePizzaProductEnterpriseBean.java @@ -124,7 +124,7 @@ public abstract class BasePizzaProductEnterpriseBean extends BasePizzaEnterprise *

* @param detachedProduct Product instance to merge *

- * @return Detached product instance + * @return Managed product instance */ protected Product mergeProductData (final Product detachedProduct) { // Trace message -- 2.39.5