glassfish - RestFull Api with JAX-RS and JPA returns empty json -
i have written next code json glassfish server:
@stateless @path("user") public class userprovider { @persistencecontext private entitymanager em; @get @path("{id}") @produces(mediatype.application_json) public user getuserbyid(@pathparam("id") long id) { user user = em.find(user.class, id); system.out.println(user); homecoming user; } }
i expecting json formatted user info when nail url localhost:8080//project/rest/user/1. receiving empty json object {} though print statement prints user object.
i not able understand thing doing wrong.
entity class: added getters.
@entity public class user { @id @generatedvalue(strategy = generationtype.identity) private long id; private string name; private string password; public long getid() { homecoming id; } public string getname(){ homecoming name; } }
jpa glassfish jax-rs
No comments:
Post a Comment