@Test public void testExecute() { final long userid = 98L; Query query = getEntityManager().createQuery("FROM GroupMembershipRequests WHERE groupId=8 and personId=" + userid); assertTrue(query.getResultList().isEmpty()); Boolean result = sut.execute(new RequestForGroupMembershipRequest(8L, userid)); assertTrue(result); assertEquals(1, query.getResultList().size()); }
@Override public Boolean execute(final RequestForGroupMembershipRequest inRequest) { long groupId = inRequest.getGroupId(); long personId = inRequest.getPersonId(); final String queryText = "SELECT COUNT(*) FROM GroupMembershipRequests WHERE groupId=:groupId AND personId = :personId"; Boolean needToAdd = ((Long) getEntityManager().createQuery(queryText).setParameter("groupId", groupId).setParameter( "personId", personId).getSingleResult()).equals(0L); if (needToAdd) { getEntityManager().persist(new RequestedGroupMembership(groupId, personId)); getEntityManager().flush(); } return needToAdd; }
InsertRequestForGroupMembership extends
        BaseArgDomainMapper<RequestForGroupMembershipRequest, Boolean> { @Override public Boolean execute(final RequestForGroupMembershipRequest inRequest) { long groupId = inRequest.getGroupId(); long personId = inRequest.getPersonId(); final String queryText = "SELECT COUNT(*) FROM GroupMembershipRequests WHERE groupId=:groupId AND personId = :personId"; Boolean needToAdd = ((Long) getEntityManager().createQuery(queryText).setParameter("groupId", groupId).setParameter( "personId", personId).getSingleResult()).equals(0L); if (needToAdd) { getEntityManager().persist(new RequestedGroupMembership(groupId, personId)); getEntityManager().flush(); } return needToAdd; } }
InsertRequestForGroupMembership extends
        BaseArgDomainMapper<RequestForGroupMembershipRequest, Boolean> { @Override public Boolean execute(final RequestForGroupMembershipRequest inRequest) { long groupId = inRequest.getGroupId(); long personId = inRequest.getPersonId(); final String queryText = "SELECT COUNT(*) FROM GroupMembershipRequests WHERE groupId=:groupId AND personId = :personId"; Boolean needToAdd = ((Long) getEntityManager().createQuery(queryText).setParameter("groupId", groupId).setParameter( "personId", personId).getSingleResult()).equals(0L); if (needToAdd) { getEntityManager().persist(new RequestedGroupMembership(groupId, personId)); getEntityManager().flush(); } return needToAdd; }  }
InsertRequestForGroupMembership extends
        BaseArgDomainMapper<RequestForGroupMembershipRequest, Boolean> { @Override public Boolean execute(final RequestForGroupMembershipRequest inRequest) { long groupId = inRequest.getGroupId(); long personId = inRequest.getPersonId(); final String queryText = "SELECT COUNT(*) FROM GroupMembershipRequests WHERE groupId=:groupId AND personId = :personId"; Boolean needToAdd = ((Long) getEntityManager().createQuery(queryText).setParameter("groupId", groupId).setParameter( "personId", personId).getSingleResult()).equals(0L); if (needToAdd) { getEntityManager().persist(new RequestedGroupMembership(groupId, personId)); getEntityManager().flush(); } return needToAdd; }  @Override Boolean execute(final RequestForGroupMembershipRequest inRequest); }
InsertRequestForGroupMembership extends
        BaseArgDomainMapper<RequestForGroupMembershipRequest, Boolean> { @Override public Boolean execute(final RequestForGroupMembershipRequest inRequest) { long groupId = inRequest.getGroupId(); long personId = inRequest.getPersonId(); final String queryText = "SELECT COUNT(*) FROM GroupMembershipRequests WHERE groupId=:groupId AND personId = :personId"; Boolean needToAdd = ((Long) getEntityManager().createQuery(queryText).setParameter("groupId", groupId).setParameter( "personId", personId).getSingleResult()).equals(0L); if (needToAdd) { getEntityManager().persist(new RequestedGroupMembership(groupId, personId)); getEntityManager().flush(); } return needToAdd; }  @Override Boolean execute(final RequestForGroupMembershipRequest inRequest);  }