@Test public void findTopTenFriendFeeds() { List<FeedReaderUrlCount> feedReaders = sut.findTop10FriendFeeds("1234, 12346"); assertEquals(3, feedReaders.size()); }
@SuppressWarnings("unchecked") public List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString) { List<FeedReaderUrlCount> feedList = new LinkedList<FeedReaderUrlCount>(); if (!openSocialIdString.isEmpty() && openSocialIdString != null) { Query q = entityManager .createQuery("SELECT url, count(*), feedTitle from FeedReader where openSocialId IN (" + openSocialIdString + ") group by url, feedTitle ORDER BY count(*) desc"); String theMagicNumberRuleSucks = "10"; q.setMaxResults(Integer.parseInt(theMagicNumberRuleSucks)); List<Object[]> results = (List<Object[]>) q.getResultList(); for (Object[] result : results) { FeedReaderUrlCount resultItem = new FeedReaderUrlCount(); resultItem.setUrl((String) result[0]); resultItem.setCount((Long) result[1]); resultItem.setFeedTitle((String) result[2]); feedList.add(resultItem); } } return feedList; }
FeedReaderMapper { @SuppressWarnings("unchecked") public List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString) { List<FeedReaderUrlCount> feedList = new LinkedList<FeedReaderUrlCount>(); if (!openSocialIdString.isEmpty() && openSocialIdString != null) { Query q = entityManager .createQuery("SELECT url, count(*), feedTitle from FeedReader where openSocialId IN (" + openSocialIdString + ") group by url, feedTitle ORDER BY count(*) desc"); String theMagicNumberRuleSucks = "10"; q.setMaxResults(Integer.parseInt(theMagicNumberRuleSucks)); List<Object[]> results = (List<Object[]>) q.getResultList(); for (Object[] result : results) { FeedReaderUrlCount resultItem = new FeedReaderUrlCount(); resultItem.setUrl((String) result[0]); resultItem.setCount((Long) result[1]); resultItem.setFeedTitle((String) result[2]); feedList.add(resultItem); } } return feedList; } }
FeedReaderMapper { @SuppressWarnings("unchecked") public List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString) { List<FeedReaderUrlCount> feedList = new LinkedList<FeedReaderUrlCount>(); if (!openSocialIdString.isEmpty() && openSocialIdString != null) { Query q = entityManager .createQuery("SELECT url, count(*), feedTitle from FeedReader where openSocialId IN (" + openSocialIdString + ") group by url, feedTitle ORDER BY count(*) desc"); String theMagicNumberRuleSucks = "10"; q.setMaxResults(Integer.parseInt(theMagicNumberRuleSucks)); List<Object[]> results = (List<Object[]>) q.getResultList(); for (Object[] result : results) { FeedReaderUrlCount resultItem = new FeedReaderUrlCount(); resultItem.setUrl((String) result[0]); resultItem.setCount((Long) result[1]); resultItem.setFeedTitle((String) result[2]); feedList.add(resultItem); } } return feedList; }  }
FeedReaderMapper { @SuppressWarnings("unchecked") public List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString) { List<FeedReaderUrlCount> feedList = new LinkedList<FeedReaderUrlCount>(); if (!openSocialIdString.isEmpty() && openSocialIdString != null) { Query q = entityManager .createQuery("SELECT url, count(*), feedTitle from FeedReader where openSocialId IN (" + openSocialIdString + ") group by url, feedTitle ORDER BY count(*) desc"); String theMagicNumberRuleSucks = "10"; q.setMaxResults(Integer.parseInt(theMagicNumberRuleSucks)); List<Object[]> results = (List<Object[]>) q.getResultList(); for (Object[] result : results) { FeedReaderUrlCount resultItem = new FeedReaderUrlCount(); resultItem.setUrl((String) result[0]); resultItem.setCount((Long) result[1]); resultItem.setFeedTitle((String) result[2]); feedList.add(resultItem); } } return feedList; }  @PersistenceContext void setEntityManager(final EntityManager inEntityManager); void insert(final FeedReader domainEntity); void flush(); void refresh(final FeedReader domainEntity); @SuppressWarnings("unchecked") FeedReader findFeedByOpenSocialIdAndModuleId(final String inOpenSocialId, final String inModuleId); @SuppressWarnings("unchecked") List<FeedReader> findFeedsByOpenSocialId(final String inOpenSocialId); @SuppressWarnings("unchecked") List<FeedReaderUrlCount> findTop10PublicFeeds(); @SuppressWarnings("unchecked") List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString); void delete(final long id); }
FeedReaderMapper { @SuppressWarnings("unchecked") public List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString) { List<FeedReaderUrlCount> feedList = new LinkedList<FeedReaderUrlCount>(); if (!openSocialIdString.isEmpty() && openSocialIdString != null) { Query q = entityManager .createQuery("SELECT url, count(*), feedTitle from FeedReader where openSocialId IN (" + openSocialIdString + ") group by url, feedTitle ORDER BY count(*) desc"); String theMagicNumberRuleSucks = "10"; q.setMaxResults(Integer.parseInt(theMagicNumberRuleSucks)); List<Object[]> results = (List<Object[]>) q.getResultList(); for (Object[] result : results) { FeedReaderUrlCount resultItem = new FeedReaderUrlCount(); resultItem.setUrl((String) result[0]); resultItem.setCount((Long) result[1]); resultItem.setFeedTitle((String) result[2]); feedList.add(resultItem); } } return feedList; }  @PersistenceContext void setEntityManager(final EntityManager inEntityManager); void insert(final FeedReader domainEntity); void flush(); void refresh(final FeedReader domainEntity); @SuppressWarnings("unchecked") FeedReader findFeedByOpenSocialIdAndModuleId(final String inOpenSocialId, final String inModuleId); @SuppressWarnings("unchecked") List<FeedReader> findFeedsByOpenSocialId(final String inOpenSocialId); @SuppressWarnings("unchecked") List<FeedReaderUrlCount> findTop10PublicFeeds(); @SuppressWarnings("unchecked") List<FeedReaderUrlCount> findTop10FriendFeeds(final String openSocialIdString); void delete(final long id);  }