/** * Checks if a member with the same email address is already registered. This is the only way to * easily capture the "@UniqueConstraint(columnNames = "email")" constraint from the Member class. * * @param email The email to check * @return True if the email already exists, and false otherwise */ public boolean emailAlreadyExists(String email) { Member member = null; try { member = repository.findByEmail(email); } catch (NoResultException e) { // ignore } return member != null; }
@GET @Path("/{id:[0-9][0-9]*}") @Produces(MediaType.APPLICATION_JSON) public Member lookupMemberById(@PathParam("id") long id) { Member member = repository.findById(id); if (member == null) { throw new WebApplicationException(Response.Status.NOT_FOUND); } return member; }
@GET @Produces(MediaType.APPLICATION_JSON) public List<Member> listAllMembers() { return repository.findAllOrderedByName(); }