Fórum
How get List of latest Article with DynamicQuery
Christian Schulze, modificado 11 Anos atrás.
How get List of latest Article with DynamicQuery
Junior Member Postagens: 87 Data de Entrada: 19/11/09 Postagens Recentes
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
Apoorva Prakash, modificado 11 Anos atrás.
RE: How get List of latest Article with DynamicQuery
Liferay Master Postagens: 658 Data de Entrada: 15/06/10 Postagens Recentes
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
Gwowen Fu, modificado 11 Anos atrás.
RE: How get List of latest Article with DynamicQuery
Expert Postagens: 315 Data de Entrada: 27/12/10 Postagens RecentesChristian 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