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);

No comments:

Post a Comment