@GET() @Path("all") @Produces("application/json") public Contact[] getAll() { return helper .getEntityManager() .createNamedQuery("Contact.findAll", Contact.class) .getResultList() .toArray(new Contact[0]); }
@GET() @Path("byId") @Produces("application/json") public Contact[] getbyId(@QueryParam("cid") String cid) { return helper .getEntityManager() .createNamedQuery("Contact.findById", Contact.class) .setParameter("cId", new Integer(cid)) .getResultList() .toArray(new Contact[0]); }