@Test public void testFindByLastNamePrefixWithFirstNameNoSpace() { List<Person> people = jpaPersonMapper.findPeopleByPrefix("Perfect,Ford"); assertTrue("Returned list should be empty", people.size() == 0); }
@SuppressWarnings("unchecked") public List<Person> findPeopleByPrefix(final String prefix) { String[] prefixes = prefix.split(", "); String lastName = prefixes[0]; String firstName = ""; if (prefixes.length > 1) { firstName = prefixes[1]; } Query q = getEntityManager().createQuery( "From Person where lower(lastName) LIKE :lprefix and lower(displayName) LIKE :fprefix " + "ORDER BY lastName, firstName, middleName").setParameter("lprefix", lastName.toLowerCase() + "%").setParameter("fprefix", firstName.toLowerCase() + "%"); return q.getResultList(); }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public List<Person> findPeopleByPrefix(final String prefix) { String[] prefixes = prefix.split(", "); String lastName = prefixes[0]; String firstName = ""; if (prefixes.length > 1) { firstName = prefixes[1]; } Query q = getEntityManager().createQuery( "From Person where lower(lastName) LIKE :lprefix and lower(displayName) LIKE :fprefix " + "ORDER BY lastName, firstName, middleName").setParameter("lprefix", lastName.toLowerCase() + "%").setParameter("fprefix", firstName.toLowerCase() + "%"); return q.getResultList(); } }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public List<Person> findPeopleByPrefix(final String prefix) { String[] prefixes = prefix.split(", "); String lastName = prefixes[0]; String firstName = ""; if (prefixes.length > 1) { firstName = prefixes[1]; } Query q = getEntityManager().createQuery( "From Person where lower(lastName) LIKE :lprefix and lower(displayName) LIKE :fprefix " + "ORDER BY lastName, firstName, middleName").setParameter("lprefix", lastName.toLowerCase() + "%").setParameter("fprefix", firstName.toLowerCase() + "%"); return q.getResultList(); } PersonMapper(final QueryOptimizer inQueryOptimizer); }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public List<Person> findPeopleByPrefix(final String prefix) { String[] prefixes = prefix.split(", "); String lastName = prefixes[0]; String firstName = ""; if (prefixes.length > 1) { firstName = prefixes[1]; } Query q = getEntityManager().createQuery( "From Person where lower(lastName) LIKE :lprefix and lower(displayName) LIKE :fprefix " + "ORDER BY lastName, firstName, middleName").setParameter("lprefix", lastName.toLowerCase() + "%").setParameter("fprefix", firstName.toLowerCase() + "%"); return q.getResultList(); } PersonMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") Person findByAccountId(final String accountId); @SuppressWarnings("unchecked") Person findByOpenSocialId(final String openSocialId); void addFollower(final long followerId, final long followingId); void removeFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String accountId, final int start, final int end); PagedSet<Followable> getFollowing(final String accountId, final int start, final int end); @SuppressWarnings("unchecked") boolean isFollowing(final String followerAccountId, final String followingAccountId); @SuppressWarnings("unchecked") List<Person> findPeopleByPrefix(final String prefix); @SuppressWarnings("unchecked") List<Person> findPeopleByOpenSocialIds(final List<String> openSocialIds); @SuppressWarnings("unchecked") List<Person> findPeopleFollowedUsingFollowerOpenSocialIds(final List<String> openSocialIds); }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public List<Person> findPeopleByPrefix(final String prefix) { String[] prefixes = prefix.split(", "); String lastName = prefixes[0]; String firstName = ""; if (prefixes.length > 1) { firstName = prefixes[1]; } Query q = getEntityManager().createQuery( "From Person where lower(lastName) LIKE :lprefix and lower(displayName) LIKE :fprefix " + "ORDER BY lastName, firstName, middleName").setParameter("lprefix", lastName.toLowerCase() + "%").setParameter("fprefix", firstName.toLowerCase() + "%"); return q.getResultList(); } PersonMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") Person findByAccountId(final String accountId); @SuppressWarnings("unchecked") Person findByOpenSocialId(final String openSocialId); void addFollower(final long followerId, final long followingId); void removeFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String accountId, final int start, final int end); PagedSet<Followable> getFollowing(final String accountId, final int start, final int end); @SuppressWarnings("unchecked") boolean isFollowing(final String followerAccountId, final String followingAccountId); @SuppressWarnings("unchecked") List<Person> findPeopleByPrefix(final String prefix); @SuppressWarnings("unchecked") List<Person> findPeopleByOpenSocialIds(final List<String> openSocialIds); @SuppressWarnings("unchecked") List<Person> findPeopleFollowedUsingFollowerOpenSocialIds(final List<String> openSocialIds);  }