@Override
public boolean acceptFriendRequest(String friendUsername, String username) {
TypedQuery<JpaPersonAssociation> query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, username);
query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, friendUsername);
JpaPersonAssociation receiverItem = getSingleResult(query.getResultList());
receiverItem.setStatus(FriendRequestStatus.ACCEPTED);
receiverItem = saveOrUpdate(receiverItem.getEntityId(), manager, receiverItem);
query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, friendUsername);
query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, username);
JpaPersonAssociation senderItem = getSingleResult(query.getResultList());
senderItem.setStatus(FriendRequestStatus.ACCEPTED);
senderItem = saveOrUpdate(senderItem.getEntityId(), manager, senderItem);
if(receiverItem.getEntityId()!=null && senderItem.getEntityId()!=null)
return true;
else
return false;
}