From 74b1072618968409c87f527d751e012f43f72d58 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 31 Jan 2023 14:22:06 +0100 Subject: [PATCH] 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 --- .../jcustomercore/model/customer/ContactCustomer.java | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.39.5