掲示板
How get List of latest Article with DynamicQuery
11年前 に Christian Schulze によって更新されました。
How get List of latest Article with DynamicQuery
Junior Member 投稿: 87 参加年月日: 09/11/19 最新の投稿
Hello,
I want to get a List of latest JournalArticle for a given List of articleIds. I mean that I want to get the latest JournalArticle with the highest version. But for n JournalArticle with one query.
I try this
But get an Exception that Double can't be cast to JournalArticle. But how can I build a DynamicQuery to get a List of JournalArticle by max version?
regards Chris
I want to get a List of latest JournalArticle for a given List of articleIds. I mean that I want to get the latest JournalArticle with the highest version. But for n JournalArticle with one query.
I try this
final Object[] array = articleIds.toArray();
final DynamicQuery query = DynamicQueryFactoryUtil.forClass(JournalArticle.class, PortalClassLoaderUtil.getClassLoader());
query.add(PropertyFactoryUtil.forName("articleId").in(array));
query.setProjection(ProjectionFactoryUtil.max("version"));
final List<journalarticle> dynamicQuery = JournalArticleLocalServiceUtil.dynamicQuery(query);
</journalarticle>
But get an Exception that Double can't be cast to JournalArticle. But how can I build a DynamicQuery to get a List of JournalArticle by max version?
regards Chris
11年前 に Apoorva Prakash によって更新されました。
RE: How get List of latest Article with DynamicQuery
Liferay Master 投稿: 658 参加年月日: 10/06/15 最新の投稿
Hi Christian,
Can't say much about dynamic query, but the second function in this link works the same...
Hope this will help...
Thanks and Regards,
Apoorva Prakash
Can't say much about dynamic query, but the second function in this link works the same...
Hope this will help...
Thanks and Regards,
Apoorva Prakash
11年前 に Gwowen Fu によって更新されました。
RE: How get List of latest Article with DynamicQuery
Expert 投稿: 315 参加年月日: 10/12/27 最新の投稿Christian Schulze:
But get an Exception that Double can't be cast to JournalArticle. But how can I build a DynamicQuery to get a List of JournalArticle by max version?
It is because the projection and it only returns data from "version" column.
Regards,
Gwowen