@Test public void testFindTopBackgroundItemsByType() { List<String> results = jpaBackgroundMapper.findBackgroundItemNamesByType(BackgroundItemType.SKILL, "skill", 5); assertEquals(3, results.size()); results = jpaBackgroundMapper.findBackgroundItemNamesByType(BackgroundItemType.SKILL, "SkIlL", 5); assertEquals(3, results.size()); results = jpaBackgroundMapper.findBackgroundItemNamesByType(BackgroundItemType.HONOR, "honor", 5); assertEquals(3, results.size()); results = jpaBackgroundMapper.findBackgroundItemNamesByType(BackgroundItemType.HONOR, "honor", 2); assertEquals(2, results.size()); }
@SuppressWarnings("unchecked") public List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType, final String searchString, final int maxResults) { String searchParam = searchString + "%"; Query q = getEntityManager().createQuery( "SELECT distinct(b.name) FROM BackgroundItem b " + "WHERE b.backgroundType=:backgroundType AND lower(b.name) LIKE :searchParam").setParameter( "backgroundType", backgroundType).setParameter("searchParam", searchParam.toLowerCase()).setMaxResults( maxResults); List<String> results = q.getResultList(); return results; }
BackgroundMapper extends DomainEntityMapper<Background> { @SuppressWarnings("unchecked") public List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType, final String searchString, final int maxResults) { String searchParam = searchString + "%"; Query q = getEntityManager().createQuery( "SELECT distinct(b.name) FROM BackgroundItem b " + "WHERE b.backgroundType=:backgroundType AND lower(b.name) LIKE :searchParam").setParameter( "backgroundType", backgroundType).setParameter("searchParam", searchParam.toLowerCase()).setMaxResults( maxResults); List<String> results = q.getResultList(); return results; } }
BackgroundMapper extends DomainEntityMapper<Background> { @SuppressWarnings("unchecked") public List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType, final String searchString, final int maxResults) { String searchParam = searchString + "%"; Query q = getEntityManager().createQuery( "SELECT distinct(b.name) FROM BackgroundItem b " + "WHERE b.backgroundType=:backgroundType AND lower(b.name) LIKE :searchParam").setParameter( "backgroundType", backgroundType).setParameter("searchParam", searchParam.toLowerCase()).setMaxResults( maxResults); List<String> results = q.getResultList(); return results; } BackgroundMapper(final QueryOptimizer inQueryOptimizer, final PersonMapper inPersonMapper); }
BackgroundMapper extends DomainEntityMapper<Background> { @SuppressWarnings("unchecked") public List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType, final String searchString, final int maxResults) { String searchParam = searchString + "%"; Query q = getEntityManager().createQuery( "SELECT distinct(b.name) FROM BackgroundItem b " + "WHERE b.backgroundType=:backgroundType AND lower(b.name) LIKE :searchParam").setParameter( "backgroundType", backgroundType).setParameter("searchParam", searchParam.toLowerCase()).setMaxResults( maxResults); List<String> results = q.getResultList(); return results; } BackgroundMapper(final QueryOptimizer inQueryOptimizer, final PersonMapper inPersonMapper); @SuppressWarnings("unchecked") Background findPersonBackground(final String inOpenSocialId); void delete(final Background inBackground); void deleteItem(final BackgroundItem item); @SuppressWarnings("unchecked") Background findOrCreatePersonBackground(final String inOpenSocialId); @SuppressWarnings("unchecked") List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType,
            final String searchString, final int maxResults); void flush(final String uuid); }
BackgroundMapper extends DomainEntityMapper<Background> { @SuppressWarnings("unchecked") public List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType, final String searchString, final int maxResults) { String searchParam = searchString + "%"; Query q = getEntityManager().createQuery( "SELECT distinct(b.name) FROM BackgroundItem b " + "WHERE b.backgroundType=:backgroundType AND lower(b.name) LIKE :searchParam").setParameter( "backgroundType", backgroundType).setParameter("searchParam", searchParam.toLowerCase()).setMaxResults( maxResults); List<String> results = q.getResultList(); return results; } BackgroundMapper(final QueryOptimizer inQueryOptimizer, final PersonMapper inPersonMapper); @SuppressWarnings("unchecked") Background findPersonBackground(final String inOpenSocialId); void delete(final Background inBackground); void deleteItem(final BackgroundItem item); @SuppressWarnings("unchecked") Background findOrCreatePersonBackground(final String inOpenSocialId); @SuppressWarnings("unchecked") List<String> findBackgroundItemNamesByType(final BackgroundItemType backgroundType,
            final String searchString, final int maxResults); void flush(final String uuid);  }