当前,我在PUT上苦苦挣扎,总是收到500个请求失败。
用户
{"id": 3,
"firstname": "lmao",
"lastname": "test",
"username": "test",
"password": "test",
"created": "2018-08-12",
"locks": []
}
来源
@PUT
@Path("user/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public void editUser(@PathParam("id") int id, User u) {
long i = (long) id;
u.setId(i);
rep.updateUser(u);
}
存储库
public void updateUser(User u) {
User user = (User) em.find(User.class, u.getId());
if (user != null) {
user = u;
em.getTransaction().begin();
em.refresh(user);
em.getTransaction().commit();
}
}