예제 #1
0
 private boolean isGroupMember(final User user, final GroupImpl group) {
   final Query query =
       entityManager.createNativeQuery(
           "select 1 from GROUP_USER where USER_ID=:userId AND GROUP_ID=:groupId");
   query.setParameter("userId", user.getId());
   query.setParameter("groupId", group.getId());
   return query.getResultList().size() > 0;
 }
예제 #2
0
 public Group createGroup(final User user, final String name, final String description)
     throws NameClashException {
   final GroupImpl group = new GroupImpl(name, user, description, new Date());
   try {
     entityManager.persist(group);
     joinGroup(user, group.getId());
     return group;
   } catch (EntityExistsException e) {
     throw new NameClashException();
   }
 }
예제 #3
0
 private void updateLastGroupVisit(final User user, final GroupImpl group) {
   if (group != null) {
     final Query query =
         entityManager.createNativeQuery(
             "update GROUP_USER SET LAST_VISIT=:now where GROUP_ID=:groupId and USER_ID=:userId");
     query.setParameter("now", new Date());
     query.setParameter("groupId", group.getId());
     query.setParameter("userId", user.getId());
     query.executeUpdate();
   }
 }