@Test public void testIsFollowing() { assertTrue(jpaPersonMapper.isFollowing("smithers", "mrburns")); assertTrue(jpaPersonMapper.isFollowing("mrburns", "smithers")); assertFalse(jpaPersonMapper.isFollowing("abc", "123")); }
@SuppressWarnings("unchecked") public boolean isFollowing(final String followerAccountId, final String followingAccountId) { Query q = getEntityManager().createQuery( "FROM Person as follower" + " inner join follower.following as following" + " where follower.accountId=:followerAccountId and" + " following.accountId=:followingAccountId").setParameter("followerAccountId", followerAccountId).setParameter("followingAccountId", followingAccountId); List<Person> results = q.getResultList(); return (results.size() != 0); }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public boolean isFollowing(final String followerAccountId, final String followingAccountId) { Query q = getEntityManager().createQuery( "FROM Person as follower" + " inner join follower.following as following" + " where follower.accountId=:followerAccountId and" + " following.accountId=:followingAccountId").setParameter("followerAccountId", followerAccountId).setParameter("followingAccountId", followingAccountId); List<Person> results = q.getResultList(); return (results.size() != 0); } }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public boolean isFollowing(final String followerAccountId, final String followingAccountId) { Query q = getEntityManager().createQuery( "FROM Person as follower" + " inner join follower.following as following" + " where follower.accountId=:followerAccountId and" + " following.accountId=:followingAccountId").setParameter("followerAccountId", followerAccountId).setParameter("followingAccountId", followingAccountId); List<Person> results = q.getResultList(); return (results.size() != 0); } PersonMapper(final QueryOptimizer inQueryOptimizer); }
PersonMapper extends DomainEntityMapper<Person> implements FollowMapper { @SuppressWarnings("unchecked") public boolean isFollowing(final String followerAccountId, final String followingAccountId) { Query q = getEntityManager().createQuery( "FROM Person as follower" + " inner join follower.following as following" + " where follower.accountId=:followerAccountId and" + " following.accountId=:followingAccountId").setParameter("followerAccountId", followerAccountId).setParameter("followingAccountId", followingAccountId); List<Person> results = q.getResultList(); return (results.size() != 0); } 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 boolean isFollowing(final String followerAccountId, final String followingAccountId) { Query q = getEntityManager().createQuery( "FROM Person as follower" + " inner join follower.following as following" + " where follower.accountId=:followerAccountId and" + " following.accountId=:followingAccountId").setParameter("followerAccountId", followerAccountId).setParameter("followingAccountId", followingAccountId); List<Person> results = q.getResultList(); return (results.size() != 0); } 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);  }