javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ...

Kuali JIRA | Chris Mann | 3 years ago
tip
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    This error was reported by the implementing institution functional team. I was able to reproduce on my local instance and debug it. I patch file is attached to this issue. h3. Steps to Reproduce (from user): - Attempted to create a new course offering by copying an existing offering. - It blew up and I received a Stacktrace. The steps are listed below. - Logged into dev, http://umd-enr.dev.umd.edu/login.jsp - Clicked on Manage Course Offerings - Term = 201208, Course = HIST, clicked the Show button - In the listing of History courses, clicked Copy in the Actions column for HIST137 - On the Copy Course Offering Page, under Options checked "Exclude scheduling information" and "Exclude instructor information." Clicked the Create button. - It loads for a few seconds and then blows up and I recieve a Stacktrace. - - This one happebned at 1:54pm on 11/27.13. I've copied it as a text file and attached. h3. SUMMARY This bug occurs when copying a course offering. The createFromCopy(...) method calls rolloverCourseOffering(...) in the service impl, and this calls a similar method in CourseOfferingServiceBusinessLogicImpl.rolloverCourseOffering(...). As the copy is performed, the code tries to copy the waitlist for each AO in the method _RCO_copyWaitlistForTargetAO_CopyCO(...). If the waitlist for the AO is empty, the code attempts to create a default waitlist using the method _RCO_createDefaultWaitlistForTargetAo(..). The bug is in _RCO_createDefaultWaitlistForTargetAo(...). 1. _RCO_createDefaultWaitlistForTargetAo() line 832 calls CourseWaitListServiceFacadeImpl.createDefaultCourseWaitlist(). CourseWaitListServiceFacadeImpl.createDefaultCourseWaitlist() line 203 calls courseWaitListService.createCourseWaitList(), saves the object to the database, and returns the object with its ID set. {code} 203 courseWaitListInfo = courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, 204 courseWaitListInfo, context); {code} 2. _RCO_createDefaultWaitlistForTargetAo line 836 then calls the same method with the same ID, resulting in the exceptions: {code} 836 courseWaitListInfo = courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, courseWaitListInfo, context); {code} h3. Details 1. Method CourseOfferingServiceBusinessLogicImpl._RCO_createDefaultWaitlistForTargetAo() line 830-836 calls getCourseWaitListServiceFacade().createDefaultCourseWaitlist(...). The call returns the variable "theWaitListInfo". Here is the code with the call. {code} // This is an exceptional case where the source AO lacks a waitlist. All AOs should have waitlists in // the ref data CourseWaitListInfo theWaitListInfo = getCourseWaitListServiceFacade().createDefaultCourseWaitlist(targetFo.getId(), targetAo.getId(), targetCo.getHasWaitlist(), context); {code} Here is the result object of the call (converted to XML). You can see the ID is now set to e7f103d1-fa5c-44b1-8d58-b9c46f256f1a {code} <org.kuali.student.enrollment.coursewaitlist.dto.CourseWaitListInfo> ... <id>e7f103d1-fa5c-44b1-8d58-b9c46f256f1a</id> ... </org.kuali.student.enrollment.coursewaitlist.dto.CourseWaitListInfo> {code} 2. The next line calls courseWaitListService.createCourseWaitList(...). It passes in theWaitListInfo with the ID set on it. courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, theWaitListInfo, context); The call tries to persist the same entity with the same ID. Here is what it's trying to persist. {code} <org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity> <id>e7f103d1-fa5c-44b1-8d58-b9c46f256f1a</id> </org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity> {code} It throws the exception. {code} javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ... at $Proxy246.persist(Unknown Source) at org.kuali.student.r2.common.dao.GenericEntityDao.persist(GenericEntityDao.java:201) at org.kuali.student.enrollment.class2.coursewaitlist.service.impl.CourseWaitListServiceImpl.createCourseWaitList(CourseWaitListServiceImpl.java:60) ... {code} h3. Fix 1. Remove line 836. The waitlist was already persisted when createDefaultCourseWaitlist() was called. It does not need to be persisted a second time (that I can tell). 2. Add a unit test for this case. UMD Ticket: https://issues.umd.edu/browse/UMDENR-308 KS Ticket: https://jira.kuali.org/browse/KSENROLL-11113

    Kuali JIRA | 3 years ago | Chris Mann
    javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ...
  2. 0

    This error was reported by the implementing institution functional team. I was able to reproduce on my local instance and debug it. I patch file is attached to this issue. h3. Steps to Reproduce (from user): - Attempted to create a new course offering by copying an existing offering. - It blew up and I received a Stacktrace. The steps are listed below. - Logged into dev, http://umd-enr.dev.umd.edu/login.jsp - Clicked on Manage Course Offerings - Term = 201208, Course = HIST, clicked the Show button - In the listing of History courses, clicked Copy in the Actions column for HIST137 - On the Copy Course Offering Page, under Options checked "Exclude scheduling information" and "Exclude instructor information." Clicked the Create button. - It loads for a few seconds and then blows up and I recieve a Stacktrace. - - This one happebned at 1:54pm on 11/27.13. I've copied it as a text file and attached. h3. SUMMARY This bug occurs when copying a course offering. The createFromCopy(...) method calls rolloverCourseOffering(...) in the service impl, and this calls a similar method in CourseOfferingServiceBusinessLogicImpl.rolloverCourseOffering(...). As the copy is performed, the code tries to copy the waitlist for each AO in the method _RCO_copyWaitlistForTargetAO_CopyCO(...). If the waitlist for the AO is empty, the code attempts to create a default waitlist using the method _RCO_createDefaultWaitlistForTargetAo(..). The bug is in _RCO_createDefaultWaitlistForTargetAo(...). 1. _RCO_createDefaultWaitlistForTargetAo() line 832 calls CourseWaitListServiceFacadeImpl.createDefaultCourseWaitlist(). CourseWaitListServiceFacadeImpl.createDefaultCourseWaitlist() line 203 calls courseWaitListService.createCourseWaitList(), saves the object to the database, and returns the object with its ID set. {code} 203 courseWaitListInfo = courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, 204 courseWaitListInfo, context); {code} 2. _RCO_createDefaultWaitlistForTargetAo line 836 then calls the same method with the same ID, resulting in the exceptions: {code} 836 courseWaitListInfo = courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, courseWaitListInfo, context); {code} h3. Details 1. Method CourseOfferingServiceBusinessLogicImpl._RCO_createDefaultWaitlistForTargetAo() line 830-836 calls getCourseWaitListServiceFacade().createDefaultCourseWaitlist(...). The call returns the variable "theWaitListInfo". Here is the code with the call. {code} // This is an exceptional case where the source AO lacks a waitlist. All AOs should have waitlists in // the ref data CourseWaitListInfo theWaitListInfo = getCourseWaitListServiceFacade().createDefaultCourseWaitlist(targetFo.getId(), targetAo.getId(), targetCo.getHasWaitlist(), context); {code} Here is the result object of the call (converted to XML). You can see the ID is now set to e7f103d1-fa5c-44b1-8d58-b9c46f256f1a {code} <org.kuali.student.enrollment.coursewaitlist.dto.CourseWaitListInfo> ... <id>e7f103d1-fa5c-44b1-8d58-b9c46f256f1a</id> ... </org.kuali.student.enrollment.coursewaitlist.dto.CourseWaitListInfo> {code} 2. The next line calls courseWaitListService.createCourseWaitList(...). It passes in theWaitListInfo with the ID set on it. courseWaitListService.createCourseWaitList(CourseWaitListServiceConstants.COURSE_WAIT_LIST_WAIT_TYPE_KEY, theWaitListInfo, context); The call tries to persist the same entity with the same ID. Here is what it's trying to persist. {code} <org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity> <id>e7f103d1-fa5c-44b1-8d58-b9c46f256f1a</id> </org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity> {code} It throws the exception. {code} javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ... at $Proxy246.persist(Unknown Source) at org.kuali.student.r2.common.dao.GenericEntityDao.persist(GenericEntityDao.java:201) at org.kuali.student.enrollment.class2.coursewaitlist.service.impl.CourseWaitListServiceImpl.createCourseWaitList(CourseWaitListServiceImpl.java:60) ... {code} h3. Fix 1. Remove line 836. The waitlist was already persisted when createDefaultCourseWaitlist() was called. It does not need to be persisted a second time (that I can tell). 2. Add a unit test for this case. UMD Ticket: https://issues.umd.edu/browse/UMDENR-308 KS Ticket: https://jira.kuali.org/browse/KSENROLL-11113

    Kuali JIRA | 3 years ago | Chris Mann
    javax.persistence.EntityExistsException: a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ...

    Root Cause Analysis

    1. javax.persistence.EntityExistsException

      a different object with the same identifier value was already associated with the session: [org.kuali.student.enrollment.class2.coursewaitlist.model.CourseWaitListEntity#e7f103d1-fa5c-44b1-8d58-b9c46f256f1a] ...

      at $Proxy246.persist()
    2. Unknown
      $Proxy246.persist
      1. $Proxy246.persist(Unknown Source)
      1 frame
    3. org.kuali.student
      CourseWaitListServiceImpl.createCourseWaitList
      1. org.kuali.student.r2.common.dao.GenericEntityDao.persist(GenericEntityDao.java:201)
      2. org.kuali.student.enrollment.class2.coursewaitlist.service.impl.CourseWaitListServiceImpl.createCourseWaitList(CourseWaitListServiceImpl.java:60)
      2 frames