Created
January 9, 2012 20:33
-
-
Save jamesfalkner/1584792 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calendar now = Calendar.getInstance(); | |
Calendar lastmonth = Calendar.getInstance(); | |
lastmonth.add(Calendar.MONTH, -1); | |
DynamicQuery q = DynamicQueryFactoryUtil.forClass(MBThread.class); | |
/* threads with categoryId == -1 are for things other than message boards, like comments on blogs, etc */ | |
q.add(RestrictionsFactoryUtil.ne("categoryId", -1L)); | |
q.add(RestrictionsFactoryUtil.eq("groupId", 14L)); | |
q.add(RestrictionsFactoryUtil.eq("companyId", 1L)); | |
q.add(RestrictionsFactoryUtil.eq("status", 0L)); | |
q.add(RestrictionsFactoryUtil.between("lastPostDate", now.getTime(), lastmonth.getTime())); | |
q.setProjection(ProjectionFactoryUtil.property("threadId")); | |
List<Long> res1 = MBThreadLocalServiceUtil.dynamicQuery(q); | |
DynamicQuery q2 = DynamicQueryFactoryUtil.forClass(MBMessage.class); | |
q2.add(RestrictionsFactoryUtil.in("threadId", res1)); | |
q2.add(RestrictionsFactoryUtil.between("createDate", now.getTime(), lastmonth.getTime())); | |
q2.setProjection( | |
ProjectionFactoryUtil.projectionList() | |
.add(ProjectionFactoryUtil.groupProperty("threadId")) | |
.add(ProjectionFactoryUtil.rowCount())); | |
List<Object> res2 = MBMessageLocalServiceUtil.dynamicQuery(q2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment