]> git.mxchange.org Git - jcustomer-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 13:22:06 +0000 (14:22 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 13:22:06 +0000 (14:22 +0100)
- 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

src/org/mxchange/jcustomercore/model/customer/ContactCustomer.java

index 593fe47e8d933dedbf22097aa3fffb955dbed38c..f601eadd7819755a3c0963fd3bb63b0927be5ec6 100644 (file)
@@ -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