From: Roland Häder Date: Wed, 10 Aug 2016 12:53:58 +0000 (+0200) Subject: Fixed: (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=eb8c78dcd0b15d041f911cf308be65cd1f504391;p=jfinancials-mailer-ejb.git 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) --- diff --git a/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java index acb4f6a..c9f1ce6 100644 --- a/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java @@ -67,8 +67,11 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookDatabaseBea 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()));