From: Roland Häder Date: Tue, 31 Jan 2023 13:22:06 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=74b1072618968409c87f527d751e012f43f72d58;p=jcustomer-core.git Continued: - the to-be-referenced contact instance need to be persisted first, an existing primary key (we believe here it isn't fake) is a good indication for that --- diff --git a/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java b/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java index 593fe47..f601ead 100644 --- a/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java +++ b/src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java @@ -16,6 +16,7 @@ */ package org.mxchange.jcustomercore.model.customer; +import java.text.MessageFormat; import java.util.Date; import java.util.Objects; import javax.persistence.Basic; @@ -151,6 +152,12 @@ public class ContactCustomer implements Customer { } else if (null == customerContact) { // Throw NPE again throw new NullPointerException("customerContact is null"); //NOI18N + } else if (customerContact.getContactId() == null) { + // Throw NPE again + throw new NullPointerException("customerContact.contactId is null"); //NOI18N + } else if (customerContact.getContactId() < 1) { + // Throw IAE + throw new IllegalArgumentException(MessageFormat.format("customerContact.contactId={0} is invalid", customerContact.getContactId())); //NOI18N } else if (null == customerNumber) { // Throw NPE again throw new NullPointerException("customerNumber is null"); //NOI18N