From a999721cf0dab94f97516c11c8d94f91cda5fe4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 23 Jun 2017 20:47:20 +0200 Subject: [PATCH] Please cherry-pick: - renamed detachedFoo -> managedFoo - used new copyAll() methods MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../database/BaseFinancialsDatabaseBean.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java index d7da3e2..ecbbe88 100644 --- a/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java +++ b/src/org/mxchange/jfinancials/database/BaseFinancialsDatabaseBean.java @@ -25,6 +25,7 @@ import javax.jms.JMSException; import javax.jms.ObjectMessage; import javax.mail.Address; import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jcontacts.contact.ContactUtils; import org.mxchange.jcoreee.database.BaseDatabaseBean; import org.mxchange.jmailee.model.delivery.wrapper.EmailDeliveryWrapper; import org.mxchange.jmailee.model.delivery.wrapper.WrapableEmailDelivery; @@ -298,49 +299,49 @@ public abstract class BaseFinancialsDatabaseBean extends BaseDatabaseBean { /** * Merges given contact's data *

- * @param contact Contact instance to merge + * @param detachedContact Contact instance to merge *

* @return Detached contact instance */ - protected Contact mergeContactData (final Contact contact) { + protected Contact mergeContactData (final Contact detachedContact) { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: contact={0} - CALLED!", contact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - CALLED!", detachedContact)); //NOI18N // The contact instance must be valid - if (null == contact) { + if (null == detachedContact) { // Throw NPE again - throw new NullPointerException("contact is null"); //NOI18N - } else if (contact.getContactId() == null) { + throw new NullPointerException("detachedContact is null"); //NOI18N + } else if (detachedContact.getContactId() == null) { // Throw NPE again - throw new NullPointerException("contact.contactId is null"); //NOI18N //NOI18N - } else if (contact.getContactId() < 1) { + throw new NullPointerException("detachedContact.contactId is null"); //NOI18N //NOI18N + } else if (detachedContact.getContactId() < 1) { // Not valid - throw new IllegalStateException(MessageFormat.format("contact.contactId={0} is not valid.", contact.getContactId())); //NOI18N + throw new IllegalStateException(MessageFormat.format("detachedContact.contactId={0} is not valid.", detachedContact.getContactId())); //NOI18N } // Set updated timestamp - contact.setContactUpdated(new GregorianCalendar()); + detachedContact.setContactUpdated(new GregorianCalendar()); // Get contact from it and find it - Contact foundContact = this.getEntityManager().find(contact.getClass(), contact.getContactId()); + Contact foundContact = this.getEntityManager().find(detachedContact.getClass(), detachedContact.getContactId()); // Should be found - assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", contact.getContactId()); //NOI18N + assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", detachedContact.getContactId()); //NOI18N // Debug message this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: foundContact.contactId={0}", foundContact.getContactId())); //NOI18N // Merge contact instance - Contact detachedContact = this.getEntityManager().merge(foundContact); + Contact managedContact = this.getEntityManager().merge(foundContact); // Copy all - detachedContact.copyAll(contact); + ContactUtils.copyAll(detachedContact, managedContact); // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", detachedContact)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("mergeContactData: detachedContact={0} - EXIT!", managedContact)); //NOI18N // Return detached contact - return detachedContact; + return managedContact; } /** -- 2.39.5