In what ways could I improve this? Does it look good? Any security concerns? I am using Jersey, Jackson and JPA. What about the architecture? I basically have CustomerResource communicating with CustomerService and CustomerService Communicates with the Entity. The updateCustomer method is in CustomerResource. I am absolutely confused on how to do the updateCustomer request, even after looking at several resources.This is my second web service using Jersey and the first one didn't use JPA and Jackson.@Path(/customers)@Consumes(MediaType.APPLICATION_JSON)@Produces(MediaType.APPLICATION_JSON)public class CustomerResource {    private CustomerService custService;    public CustomerResource() {        this.custService = new CustomerService();    }    @GET    @Path(/{id})    public Response getCustomerId(@PathParam(id) String customerId) {        try {            Customer customer = custService.findById(Integer.parseInt(customerId));            if (customer == null) {                return Response.status(Response.Status.NOT_FOUND).entity(The following id wasn't found:  + customerId)                        .build();            }            return Response.ok(customer).build();        } catch (NumberFormatException e) {            return Response.status(Response.Status.SEE_OTHER)                    .entity(You must enter a number ------   Error  -----     :  + customerId                            + \n------------------------------------------------------------------------\n                            + e.getMessage())                    .build();        }    }    @POST    @Path(/{id})    public Response updateCustomer(String body, @PathParam(id) String customerId) {        return Response.status(Response.Status.OK).entity(body =  + body).build();    }    @DELETE    @Path(/{id})    public Response deleteCustomer(@PathParam(id) String customerId) {        Customer customer = custService.findById(Integer.parseInt(customerId));        custService.delete(customer);        return Response.status(Response.Status.OK).build();    }    @PUT    @Path()    public Response createCustomer(String body) {        ObjectMapper mapper = new ObjectMapper();        try {            List<Customer> customers = mapper.readValue(body, new TypeReference<List<Customer>>() {            });            for (Customer customer : customers) {                custService.create(customer);            }        } catch (JsonParseException e) {            return Response.status(Response.Status.BAD_REQUEST)                    .entity(An error occurred will parsing the JSON! Please double check the format of the JSON.                            + \n------------------------------------------------------------------------\n                            + e.getMessage())                    .build();        } catch (JsonMappingException e) {            e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        }        return Response.status(Response.Status.OK).build();    }    @GET    @Path()    public Response searchCustomer(@QueryParam(address) String address, @QueryParam(phoneNum) String phoneNum) {        List<Customer> customers;        if (phoneNum != null) {            customers = custService.findByPhoneNum(phoneNum);        } else if (address != null) {            customers = custService.findByAddress(address);        } else {            return Response.status(Response.Status.BAD_REQUEST).entity(You must use the correct URL pattern.).build();        }        return Response.status(Response.Status.OK).entity(customers).build();    }}Service Layerpublic class CustomerService extends GenericService<Customer, Integer>{    public CustomerService() {        super(Customer.class);    }    public List<Customer> findByAddress(String address) {         TypedQuery<Customer> query =                 super.getManager().createNamedQuery(Customer.findByAddress, Customer.class);         query.setParameter(address, address);         return query.getResultList();    }    public List<Customer> findByPhoneNum(String phoneNum) {         TypedQuery<Customer> query =                 super.getManager().createNamedQuery(Customer.findByPhoneNum, Customer.class);         query.setParameter(phoneNum, phoneNum);         return query.getResultList();    }}public abstract class GenericService<T, Id> {    private EntityManager manager;    private final Class<T> entityType;    public GenericService(Class<T> entityType) {        manager = DatabaseUtil.getSessionFactory().createEntityManager();        this.entityType = entityType;    }    public void shutdown() {        manager.close();    }    public void update(T entity) {        manager.merge(entity);    }    public void create(T entity) {        manager.persist(entity);    }    public void delete(T entity) {        manager.remove(entity);    }    public T findById(Id id) {        return manager.find(entityType, id);    }    protected void beginTransaction() {        manager.getTransaction().begin();    }    protected void saveChanges() {        manager.getTransaction().commit();    }    protected EntityManager getManager() {        return this.manager;    }}Entity@Entity@Table(name = Customer)@NamedQueries({    @NamedQuery(name=Customer.findByAddress,                query=SELECT * FROM Customers c where c.address = :address),    @NamedQuery(name=Customer.findByPhoneNum,                query=SELECT * FROM Customers c where c.phoneNum = :phoneNum)})public class Customer {    @Id @GeneratedValue(strategy=GenerationType.IDENTITY)    private int id;    private String firstName;    private String lastName;    private String address;    private String phoneNum;    public int getId() {        return id;    }    public String getFirstName() {        return firstName;    }    public void setFirstName(String firstName) {        this.firstName = firstName;    }    public String getLastName() {        return lastName;    }    public void setLastName(String lastName) {        this.lastName = lastName;    }    public String getAddress() {        return address;    }    public void setAddress(String address) {        this.address = address;    }    public String getPhoneNum() {        return phoneNum;    }    public void setPhoneNum(String phoneNum) {        this.phoneNum = phoneNum;    }}
REST web service to interface with a customer database
java;database;rest;jpa;jersey