Showing posts with label example of dynamic Query In Liferay. Show all posts
Showing posts with label example of dynamic Query In Liferay. Show all posts

Friday, 25 May 2012

Write a dynamic query in liferay.


Created a query to find a Categories which has "country" into its name.

DynamicQuery dynamicQuery =DynamicQueryFactoryUtil.forClass(MBCategory.class,PortalClassLoaderUtil.getClassLoader());
        dynamicQuery.add(PropertyFactoryUtil.forName("name").like("%Country %"));

Return the category list which has country into its name.
List<MbCategory> categories =  MBCategoryLocalServiceUtil.dynamicQuery(dynamicQuery);