private void unlinkToUser(UserDocument entity) {
   if (entity != null) {
     Users user = entity.getUser();
     if (user != null) {
       user.removeDocument(entity);
     }
   }
 }
 @Override
 public void delete(Users user) throws ApplicationException {
   Query query = getEntityManager().createNamedQuery(UserDocument.deleteFromUser);
   query.setParameter(1, user).executeUpdate();
   user.getDocuments().clear();
 }