From b340f6ef4bad5d7de6ab21e5d9e1ad307dec4d80 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 20 May 2020 20:34:41 +0200 Subject: [PATCH] Please cherry-pick: - always set EntryUpdated in the managed (and merged) instance, as the copyFooData() methods do no longer copy timestamps MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../enterprise/BasePizzaEnterpriseBean.java | 69 +++---------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/src/java/org/mxchange/pizzaapplication/enterprise/BasePizzaEnterpriseBean.java b/src/java/org/mxchange/pizzaapplication/enterprise/BasePizzaEnterpriseBean.java index 429a3e2..9e040f1 100644 --- a/src/java/org/mxchange/pizzaapplication/enterprise/BasePizzaEnterpriseBean.java +++ b/src/java/org/mxchange/pizzaapplication/enterprise/BasePizzaEnterpriseBean.java @@ -999,59 +999,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { throw new NullPointerException("fetchedNumber.phoneId is null"); //NOI18N } - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getMobileId())); //NOI18N - - // Init query instance - final DialableMobileNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getMobileId()); - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: foundNumber={0}", foundNumber)); //NOI18N - - // Default is null - DialableMobileNumber detachedNumber = null; - - // Is there a difference? - if (!MobileNumbers.isSameMobileNumber(mobileNumber, fetchedNumber)) { - // @TODO Copy all to foundNumber, then merge - - // Merge this entry - detachedNumber = this.getEntityManager().merge(foundNumber); - - // @TODO Copy all - } - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N - - // Return it - return detachedNumber; - } - - /** - * Returns a detached instance from given land-line instance - *

- * @param landLineNumber Land-line instance - * @param fetchedNumber Found land-line number in database - *

- * @return Detached instance - */ - protected DialableLandLineNumber getDetached (final DialableLandLineNumber landLineNumber, final DialableLandLineNumber fetchedNumber) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: landLineNumber={0},fetchedNumber={1} - CALLED!", landLineNumber, fetchedNumber)); //NOI18N - - // Should be valid - if (null == landLineNumber) { - // Throw NPE - throw new NullPointerException("landLineNumber is null"); //NOI18N - } else if (fetchedNumber.getPhoneId() == null) { - // ..and again - throw new NullPointerException("landLineNumber.phoneId is null"); //NOI18N - } - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("getDetached: fetchedNumber.phoneId={0}", fetchedNumber.getPhoneId())); //NOI18N - // Init query instance final DialableLandLineNumber foundNumber = this.getEntityManager().find(fetchedNumber.getClass(), fetchedNumber.getPhoneId()); @@ -1071,6 +1018,9 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { // @TODO Copy all } + // Set updated timestamp + managedBranchOffice.setBranchEntryUpdated(new Date()); + // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("getDetached: detachedNumber={0} - EXIT!", detachedNumber)); //NOI18N @@ -1151,9 +1101,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { throw new IllegalStateException(MessageFormat.format("{0}.detachedContact.contactId={1} is not valid.", this.getClass().getSimpleName(), detachedContact.getContactId())); //NOI18N } - // Set updated timestamp - detachedContact.setContactEntryUpdated(new Date()); - // Get contact from it and find it final Contact foundContact = this.createManaged(detachedContact); @@ -1166,8 +1113,8 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { // Merge contact instance final Contact managedContact = this.getEntityManager().merge(foundContact); - // Copy all - Contacts.copyAll(detachedContact, managedContact); + // Set updated timestamp + managedContact.setContactEntryUpdated(new Date()); // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.mergeContactData: managedContact={1} - EXIT!", this.getClass().getSimpleName(), managedContact)); //NOI18N @@ -1310,9 +1257,6 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { throw new IllegalStateException(MessageFormat.format("detachedDepartment.departmentId ={0} is not valid.", detachedDepartment.getDepartmentId())); //NOI18N } - // Set updated timestamp - detachedDepartment.setDepartmentEntryUpdated(new Date()); - // Get contact from it and find it final Department foundDepartment = this.createManaged(detachedDepartment); @@ -1325,6 +1269,9 @@ public abstract class BasePizzaEnterpriseBean extends BaseEnterpriseBean { // Merge contact instance final Department managedDepartment = this.getEntityManager().merge(foundDepartment); + // Set updated timestamp + managedDepartment.setDepartmentEntryUpdated(new Date()); + // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeDepartmentData: managedDepartment={0} - EXIT!", managedDepartment)); //NOI18N -- 2.39.5