On 09/26/2010 11:23 PM, Ronak Patel wrote:
> Jay,
>
> You cannot set an @Id of a JPA Entity that is a @GeneratedValue.
>
>
Thank you for your reply. For what it's worth, the following works:
@PUT
@Consumes("application/json")
@Produces("text/html")
@Path("{id}")
public String doUpdate(@PathParam id, Entity entity) {
entity.setId(id);
entity = em.merge(entity);
// entity.setId(something); <--- throws an exception for accessing
id field
return "Success";
}
So it appears that you can set the id field on an entity in an unmanaged
state. But then I still think it's weird that the marshalling code
doesn't set it.
Jay