@Test @Transactional public void testRemoveFollower() { DomainGroup group = jpaGroupMapper.findByShortName("group1"); Person burns = jpaPersonMapper.findByAccountId("mrburns"); assertEquals(0, burns.getFollowingCount()); assertEquals(1, burns.getGroupCount()); assertEquals(3, group.getFollowersCount()); assertTrue(jpaGroupMapper.isFollowing("mrburns", "group1")); jpaGroupMapper.removeFollower(burns.getId(), group.getId()); getEntityManager().clear(); group = jpaGroupMapper.findByShortName("group1"); burns = jpaPersonMapper.findByAccountId("mrburns"); assertEquals(0, burns.getFollowingCount()); assertEquals(0, burns.getGroupCount()); assertEquals(2, group.getFollowersCount()); assertFalse(jpaGroupMapper.isFollowing("mrburns", "group1")); }
public void removeFollower(final long followerId, final long followingId) { int rowsDeleted = getEntityManager() .createQuery("DELETE FROM GroupFollower where followerId=:followerId and followingId=:followingId") .setParameter("followerId", followerId).setParameter("followingId", followingId).executeUpdate(); if (rowsDeleted == 0) { return; } getEntityManager() .createQuery("update versioned Person set groupsCount = followingGroup.size where id=:followerId") .setParameter("followerId", followerId).executeUpdate(); getEntityManager() .createQuery("update versioned DomainGroup set followersCount = followers.size where id=:followingId") .setParameter("followingId", followingId).executeUpdate(); getEntityManager().flush(); getEntityManager().clear(); DomainGroup followingEntity = findById(followingId); getFullTextSession().index(followingEntity); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { public void removeFollower(final long followerId, final long followingId) { int rowsDeleted = getEntityManager() .createQuery("DELETE FROM GroupFollower where followerId=:followerId and followingId=:followingId") .setParameter("followerId", followerId).setParameter("followingId", followingId).executeUpdate(); if (rowsDeleted == 0) { return; } getEntityManager() .createQuery("update versioned Person set groupsCount = followingGroup.size where id=:followerId") .setParameter("followerId", followerId).executeUpdate(); getEntityManager() .createQuery("update versioned DomainGroup set followersCount = followers.size where id=:followingId") .setParameter("followingId", followingId).executeUpdate(); getEntityManager().flush(); getEntityManager().clear(); DomainGroup followingEntity = findById(followingId); getFullTextSession().index(followingEntity); } }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { public void removeFollower(final long followerId, final long followingId) { int rowsDeleted = getEntityManager() .createQuery("DELETE FROM GroupFollower where followerId=:followerId and followingId=:followingId") .setParameter("followerId", followerId).setParameter("followingId", followingId).executeUpdate(); if (rowsDeleted == 0) { return; } getEntityManager() .createQuery("update versioned Person set groupsCount = followingGroup.size where id=:followerId") .setParameter("followerId", followerId).executeUpdate(); getEntityManager() .createQuery("update versioned DomainGroup set followersCount = followers.size where id=:followingId") .setParameter("followingId", followingId).executeUpdate(); getEntityManager().flush(); getEntityManager().clear(); DomainGroup followingEntity = findById(followingId); getFullTextSession().index(followingEntity); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { public void removeFollower(final long followerId, final long followingId) { int rowsDeleted = getEntityManager() .createQuery("DELETE FROM GroupFollower where followerId=:followerId and followingId=:followingId") .setParameter("followerId", followerId).setParameter("followingId", followingId).executeUpdate(); if (rowsDeleted == 0) { return; } getEntityManager() .createQuery("update versioned Person set groupsCount = followingGroup.size where id=:followerId") .setParameter("followerId", followerId).executeUpdate(); getEntityManager() .createQuery("update versioned DomainGroup set followersCount = followers.size where id=:followingId") .setParameter("followingId", followingId).executeUpdate(); getEntityManager().flush(); getEntityManager().clear(); DomainGroup followingEntity = findById(followingId); getFullTextSession().index(followingEntity); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") DomainGroup findByShortName(final String groupShortName); void addFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String shortName, 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 shortName); void removeFollower(final long followerId, final long followingId); void removeGroupCoordinator(final long followerId, final long followingId); @SuppressWarnings("unchecked") Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup); void deleteById(final long id); boolean isInputUserGroupCoordinator(final long followerId, final long followingId); boolean isGroupPrivate(final long followingId); int getGroupCoordinatorCount(final long followingId); }
DomainGroupMapper extends DomainEntityMapper<DomainGroup> implements FollowMapper, CompositeEntityMapper { public void removeFollower(final long followerId, final long followingId) { int rowsDeleted = getEntityManager() .createQuery("DELETE FROM GroupFollower where followerId=:followerId and followingId=:followingId") .setParameter("followerId", followerId).setParameter("followingId", followingId).executeUpdate(); if (rowsDeleted == 0) { return; } getEntityManager() .createQuery("update versioned Person set groupsCount = followingGroup.size where id=:followerId") .setParameter("followerId", followerId).executeUpdate(); getEntityManager() .createQuery("update versioned DomainGroup set followersCount = followers.size where id=:followingId") .setParameter("followingId", followingId).executeUpdate(); getEntityManager().flush(); getEntityManager().clear(); DomainGroup followingEntity = findById(followingId); getFullTextSession().index(followingEntity); } DomainGroupMapper(final QueryOptimizer inQueryOptimizer); @SuppressWarnings("unchecked") DomainGroup findByShortName(final String groupShortName); void addFollower(final long followerId, final long followingId); PagedSet<Person> getFollowers(final String shortName, 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 shortName); void removeFollower(final long followerId, final long followingId); void removeGroupCoordinator(final long followerId, final long followingId); @SuppressWarnings("unchecked") Long[] getFollowerAndCoordinatorPersonIds(final DomainGroup domainGroup); void deleteById(final long id); boolean isInputUserGroupCoordinator(final long followerId, final long followingId); boolean isGroupPrivate(final long followingId); int getGroupCoordinatorCount(final long followingId);  }