]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
Fixed: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Wed, 10 Aug 2016 12:53:58 +0000 (14:53 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 16 Aug 2016 19:23:38 +0000 (21:23 +0200)
- 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)

src/java/org/mxchange/jphone/phonenumbers/phone/JobsAdminPhoneSessionBean.java

index 57f58c54dc9d8e01df207175c5665f8f9fc37d8d..5c381d543fcacd47dbe5ab864ad2e94152f23914 100644 (file)
@@ -67,8 +67,11 @@ public class JobsAdminPhoneSessionBean extends BaseJobsDatabaseBean implements A
                        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()));