Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Run Dynamic Queries for All Liferay Plugins Portlets Using Common Service Builder

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.30k
    Comment on it

    In this blog, I will be putting some light on how you can run dynamic queries for all liferay plugins portlets using common service builder. For this you can easily use same service builder for all Liferay plugin portlets and can create a service builder portlet which has all entities. After that, you need to import this service builder with liferay-plugin-package.properties add Required Deployment Contexts by ui or add it last required-deployment-contexts=\ServicePortlet-portlet.

    After that you are required to use dynamic queries as given below:

     

    ClassLoader classLoader = (ClassLoader)PortletBeanLocatorUtil.locate(ClpSerializer.getServletContextName(), "portletClassLoader");

    OR

    ClassLoader classLoader = PortletBeanLocatorUtil.getBeanLocator(ClpSerializer.getServletContextName()).getClassLoader();

    DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(charges.class,classLoader);

     

    ClpSerializer must be of imported service builder portlet.

    You can insert data like this:

     

    long id = CounterLocalServiceUtil.increment(XXX.class.getName());

    XXX xxx = XXXLocalServiceUtil.createXXX(id);
    XXXLocalServiceUtil.addXXX(xxx);

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: