From 682a257d3ea985fdc7a3b1a530eac5afd0e6612e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 10 Aug 2016 14:53:58 +0200 Subject: [PATCH] Fixed: (please cherry-pick) - em.remove() needs a managed entity, not a one passed from e.g. a controller - still this method may throw an exception, e.g. when an other entity (table) references this entity - but since deleteCellphoneNumber() *should* delete cell phone numbers, it doesn't care if the entity is still referenced. - this needs to be taken care of the controller and not the EJB (job-executor) --- .../phonenumbers/phone/PizzaAdminPhoneSessionBean.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java index dcb52b7..46f8f7a 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/PizzaAdminPhoneSessionBean.java @@ -67,8 +67,11 @@ public class PizzaAdminPhoneSessionBean extends BasePizzaDatabaseBean implements throw new NullPointerException(MessageFormat.format("cellphoneNumber.phoneNumber={0} is not valid.", cellPhoneNumber.getPhoneNumber())); //NOI18N } + // Merge it to get a managed entity back + DialableCellphoneNumber managedNumber = this.getEntityManager().getReference(cellPhoneNumber.getClass(), cellPhoneNumber.getPhoneId()); + // Remove it from database - this.getEntityManager().remove(cellPhoneNumber); + this.getEntityManager().remove(managedNumber); // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.deleteCellphoneData: EXIT!", this.getClass().getSimpleName())); -- 2.39.5