Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-81028

FinderCache doesn't work properly when using null values in a null convertible string column

    Details

      Description

      When using columns with String as type and null convertible caches aren't cleared properly. The reason is that we can use the null value to search, but to clear cache we use to form the key the gettter, so we never clear the elements inserted with null as key.

       

      Steps to Reproduce:

      1. Execute the following Groovy script:
        import com.liferay.journal.service.JournalContentSearchLocalServiceUtil;
        import com.liferay.counter.kernel.service.CounterLocalServiceUtil;
        import com.liferay.journal.model.JournalContentSearch;
        import com.liferay.journal.service.persistence.JournalContentSearchUtil;
        import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
        import com.liferay.portal.kernel.model.Company;
        import com.liferay.portal.kernel.service.CompanyLocalServiceUtil;
        
        long companyId = CompanyThreadLocal.getCompanyId();
        Company company = CompanyLocalServiceUtil.getCompany(companyId);
        
        long groupId = company.getGroupId();
        boolean privateLayout = false;
        long layoutId = 1L;
        String portletId = "A_PORTLET_ID";
        String articleId = null;
        
        long contentSearchId = CounterLocalServiceUtil.increment();
        JournalContentSearch contentSearch = JournalContentSearchLocalServiceUtil.createJournalContentSearch(contentSearchId);
        contentSearch.setGroupId(groupId);
        contentSearch.setCompanyId(companyId);
        contentSearch.setPrivateLayout(privateLayout);
        contentSearch.setLayoutId(layoutId);
        contentSearch.setPortletId(portletId);
        contentSearch.setArticleId(articleId);
        
        JournalContentSearchLocalServiceUtil.updateJournalContentSearch(contentSearch);
        
        JournalContentSearchLocalServiceUtil.deleteArticleContentSearch(groupId, privateLayout, layoutId, portletId, articleId);
        
        try{
            JournalContentSearchLocalServiceUtil.deleteArticleContentSearch(groupId, privateLayout, layoutId, portletId, articleId);
        } catch(Exception e) {
            out.println(e);
        }
        

      Expected Results:

      No exception should be printed when trying to remove the second time because the record is already deleted.

       

      Actual Results:

      An org.hibernate.ObjectNotFoundException is thrown because the list of records to retrieve is cached and therefore tries to delete a record that doesn't exist.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  1 year, 20 weeks, 2 days ago

                  Packages

                  Version Package
                  7.0.0 DXP FP47
                  7.0.0 DXP SP8
                  7.0.X
                  7.1.0 Beta 2
                  7.1.X
                  Master