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

DynamicQuery subselects do not work when PACL is enabled

    Details

    • Fix Priority:
      4

      Description

      When PACL is enabled creating a subselect criterion throws a ClassCastException:

      DynamicQuery subselect = DynamicQueryFactoryUtil.forClass(User.class);
      Criterion criterion = PropertyFactoryUtil.forName("userId").in(subselect); 
      //throws:
      java.lang.ClassCastException: $Proxy917 cannot be cast to com.liferay.portal.dao.orm.hibernate.DynamicQueryImpl
              at com.liferay.portal.dao.orm.hibernate.PropertyImpl.in(PropertyImpl.java:211)

      The problem is that PropertyImpl.in(DynamicQuery subselect) assumes that the DynamicQuery argument is an instance of DynamicQueryImpl.

      When PACL is enabled, the DynamicQuery returned by DynamicQueryFactoryImpl.forClass(Class<?> clazz) is only a proxy implementing DynamicQuery, but not extending DynamicQueryImpl, thus the class cast fails.

      Possibly related to LPS-33702

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Days since last comment:
                3 years, 38 weeks, 5 days ago

                Packages

                Version Package