示例#1
0
 protected TypedQuery<UserGroupMembershipEntity> getUserGroupMappingQuery(GroupModel group) {
   TypedQuery<UserGroupMembershipEntity> query =
       em.createNamedQuery("userMemberOf", UserGroupMembershipEntity.class);
   query.setParameter("user", getEntity());
   query.setParameter("groupId", group.getId());
   return query;
 }
示例#2
0
 @Override
 public void joinGroup(GroupModel group) {
   if (isMemberOf(group)) return;
   UserGroupMembershipEntity entity = new UserGroupMembershipEntity();
   entity.setUser(getEntity());
   entity.setGroupId(group.getId());
   em.persist(entity);
   em.flush();
   em.detach(entity);
 }