Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-11664

DocumentBase JPA versus OJB change regarding saving/restoring documentHeader

    Details

    • Type: Bug Fix Bug Fix
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.4
    • Fix Version/s: 2.6
    • Component/s: Development, JPA
    • Security Level: Public (Public: Anyone can view)
    • Labels:
    • Similar issues:
      KULRICE-11662DocumentService.saveDocument() JPA versus OJB behavior change
      KULRICE-9102Determine how best to handle linking to DocumentHeader using JPA as was done with OJB
      KULRICE-1848DocumentBase should not be using KNSServiceLocator.getBean()
      KULRICE-9108Implement support for loading of both OJB and JPA versions of KRAD client-side mappings
      KULRICE-4221Make sure that these JPA changes aren't negatively affecting OJB
      KULRICE-1779Convert KEW Data Access Objects from OJB to JPA
      KULRICE-1304JPA Migration
      KULRICE-11496Convert KCB entities from OJB to JPA
      KULRICE-9515Document how to convert OJB descriptor mappings to JPA
      KULRICE-6014JPA Conversion Guide
    • Rice Module:
      KRAD
    • KRAD Feature Area:
      Document
    • Application Requirement:
      KC
    • Sprint:
      2.4.0-rc1 Sprint 1, 2.4.0-rc1 Sprint 2, 2.4.0-rc1 Sprint 3, 2.4.0-rc1 Sprint 4, 2.4.0-rc1 Sprint 5, 2.4.0-rc1 Sprint 6, 2.4.0-rc1 Sprint 7, 2.4.0-rc1 Sprint 8
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Code Review Status:
      Not Required
    • Include in Release Notes?:
      Yes

      Description

      In KC we have a mixed JPA and OJB environment. Since the documentHeader is marked @Transient in the DocumentBase class there is logic to manually save and restore this reference. This logic is not working correctly for both JPA & OJB. In some cases, the documentheader becomes nulled out (from JPA) leading to exception regarding the workflow document not be found.

      In order to fix this in KC, I had to do the following in our KcTransactionalDocumentBase (formerly ResearchDocumentBase) class:

         @Override
          public void prepareForSave() {
              super.prepareForSave();
       
       //... removed KC specific logic ...
      
              documentHeader = KRADServiceLocatorWeb.getDocumentHeaderService().saveDocumentHeader(documentHeader);
          }
      
          @Override
          protected void prePersist() {
              //do not call super to remove the call to  DocumentHeaderService.saveDocumentHeader(documentHeader)
              if (StringUtils.isEmpty(getObjectId())) {
                  setObjectId(UUID.randomUUID().toString());
              }
          }
      
          @Override
          protected void postPersist() {
              super.postPersist();
              DocumentHeader temp = KRADServiceLocatorWeb.getDocumentHeaderService().getDocumentHeaderById(documentNumber);
              if (temp != null && temp.getWorkflowDocument() != null) {
                  documentHeader = temp;
              }
          }
      
          @Override
          public void postProcessSave(KualiDocumentEvent event) {
              super.postProcessSave(event);
              DocumentHeader temp =  KRADServiceLocatorWeb.getDocumentHeaderService().getDocumentHeaderById(documentNumber);
              if (temp != null && temp.getWorkflowDocument() != null) {
                  documentHeader = temp;
              }
          }
      

      I have no idea whether this is the best or the most efficient way to handle the documentHeader. I also don't know if it works in all cases but it appears to work for KC.

        Activity

        Hide
        Gayathri Athreya added a comment - - edited

        We have a workaround so marking it minor

        Show
        Gayathri Athreya added a comment - - edited We have a workaround so marking it minor
        Hide
        Kristina Taylor (Inactive) added a comment -

        We were unable to reproduce on our end, so we still need Travis to confirm whether there is still a bug or not with the latest branch version.

        Show
        Kristina Taylor (Inactive) added a comment - We were unable to reproduce on our end, so we still need Travis to confirm whether there is still a bug or not with the latest branch version.
        Hide
        Travis Schneeberger added a comment -

        This is still a bug. If I remove my workaround from our base document the header is not restored correctly.

        Show
        Travis Schneeberger added a comment - This is still a bug. If I remove my workaround from our base document the header is not restored correctly.
        Hide
        Kristina Taylor (Inactive) added a comment -

        The way I tested was locally with code that was just committed to 2.5 in https://fisheye.kuali.org/changelog/rice?cs=46800. Our test transactional document Travel Authorization will be available on env1 (when it refreshes) under the KRAD tab. I'm wondering if there's something special about your documents that is something we are not capturing.

        Show
        Kristina Taylor (Inactive) added a comment - The way I tested was locally with code that was just committed to 2.5 in https://fisheye.kuali.org/changelog/rice?cs=46800 . Our test transactional document Travel Authorization will be available on env1 (when it refreshes) under the KRAD tab. I'm wondering if there's something special about your documents that is something we are not capturing.
        Hide
        Travis Schneeberger added a comment -

        Gayathri Athreya What should we do with this JIRA?

        Show
        Travis Schneeberger added a comment - Gayathri Athreya What should we do with this JIRA?

          People

          • Assignee:
            Gayathri Athreya
            Reporter:
            Travis Schneeberger
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 2 days
              2d
              Remaining:
              Remaining Estimate - 2 days
              2d
              Logged:
              Time Spent - Not Specified
              Not Specified

                Agile

                  Structure Helper Panel