Mistři v programování na #hovnokod

Java #718

public NewsWrapper[] getTopNews() {
String query = "SELECT n FROM News n ORDER BY n.newsDate DESC";
Query q = JpaManager.getEntityManager().createQuery(query).
setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE);
ArrayList topNews = new ArrayList(q.getResultList());
ArrayList sortedTopNews = new ArrayList();
while (topNews.size() > 0) {
News newsItem = topNews.get(topNews.size() - 1);
if (newsItem.getIsPublish() && sortedTopNews.size() < TOP_NEWS_COUNT)
sortedTopNews.add(newsItem);
topNews.remove(newsItem);
}
return CommonEnt.toEntArray(NewsWrapper.class,
CommonEnt.transformEntCollection(new NewsTransformer(), sortedTopNews));
}

HovnoKod,