Details

    • Similar Issues:
      Show 5 results 

      Description

      Core models are not accessible in Dynamic Query of Plugins SDK

      in Dynamic Query of Plugins SDK, use following code in knowledge base portlet:

      DynamicQuery query = DynamicQueryFactoryUtil.forClass(Subscription.class, "subscription")
      .add(PropertyFactoryUtil.forName("subscription.companyId").eq(companyId))
      .add(PropertyFactoryUtil.forName("subscription.userId").eq(userId));

      It throws errors:

      19:43:29,500 ERROR [jsp:165] java.lang.NullPointerException
      at org.hibernate.criterion.DetachedCriteria.forClass(DetachedCriteria.java:92)
      at com.liferay.portal.dao.orm.hibernate.DynamicQueryFactoryImpl.forClass(DynamicQueryFactoryImpl.java:57)
      at com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil.forClass(DynamicQueryFactoryUtil.java:43)
      at com.liferay.knowledgebase.util.KBSearchUtil.getSubscribedArticlesCount(KBSearchUtil.java:12)

        Activity

        Hide
        Jonas Yuan added a comment - - Restricted to

        snippet at nowledge base portlet:

        public class KBSearchUtil {
        // all subscriptions
        public static int getSubscribedArticlesCount(long companyId, long groupId, long userId)

        { int number = 0; DynamicQuery query = DynamicQueryFactoryUtil.forClass(Subscription.class, "subscription") .add(PropertyFactoryUtil.forName("subscription.companyId").eq(companyId)) .add(PropertyFactoryUtil.forName("subscription.userId").eq(userId)); return number; }

        }

        Show
        Jonas Yuan added a comment - - Restricted to snippet at nowledge base portlet: public class KBSearchUtil { // all subscriptions public static int getSubscribedArticlesCount(long companyId, long groupId, long userId) { int number = 0; DynamicQuery query = DynamicQueryFactoryUtil.forClass(Subscription.class, "subscription") .add(PropertyFactoryUtil.forName("subscription.companyId").eq(companyId)) .add(PropertyFactoryUtil.forName("subscription.userId").eq(userId)); return number; } }
        Hide
        Jonas Yuan added a comment -

        at revision 43097.

        Show
        Jonas Yuan added a comment - at revision 43097.
        Hide
        Michael Han added a comment -

        pass the proper classloader in to use.

        Show
        Michael Han added a comment - pass the proper classloader in to use.
        Hide
        James Falkner added a comment -

        Re-opening to remove 6.0.6 designation (may be added back later after review).

        Show
        James Falkner added a comment - Re-opening to remove 6.0.6 designation (may be added back later after review).

          People

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

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years, 17 weeks, 6 days ago

              Development

                Structure Helper Panel