Here's a example for a SQL query with GROUP BY and COUNT function.
This is how it works with the liferay hibernate api.
SQL syntax:
SELECT classPK, COUNT(*) AS _count FROM MBMessage ORDER BY _count DESC
Dynamic Query:
ProjectionList plist = ProjectionFactoryUtil.projectionList();
plist.add(ProjectionFactoryUtil.groupProperty("classPK"));
plist.add(ProjectionFactoryUtil.rowCount(), "_count");
DynamicQuery querySub = DynamicQueryFactoryUtil.forClass(MBMessage.class, PortalClassLoaderUtil.getClassLoader())
.setProjection(plist)
.addOrder(OrderFactoryUtil.desc("_count"));
DynamicQuery query = DynamicQueryFactoryUtil.forClass(AssetEntry.class, PortalClassLoaderUtil.getClassLoader())
.add(PropertyFactoryUtil.forName("classPK").in(querySub));
List results = AssetEntryLocalServiceUtil.dynamicQuery(querySub);
LOG.info(results);
for (Object[] r : (List
Thanks for sharing these information. I find it difficult to understand how application development melbourne works. With your post, I was able to get it a bit.
ReplyDeleteLooking at all these confusing codes and numbers, one would be thankful that there are people who are into such complex process for the public to enjoy flawless mobile phone applications.
ReplyDeleteTheresa King