thekevshow
thekevshow

Reputation: 784

Post with Jax-RS

This really should be a simple question, and I apologize but I just can't seem to find the answer. From my understanding you can take in an object and have it use say a bean in Java EE to produce this Object/Entity into a database. Now the problem is the ID is going to be auto-generated so the client will not know this when first being created. How do I return with the @POST in Jax-RS what there now provided URI/ID location is so they know who they are provided that ID after being created. I have read and thought this was possible but maybe I am wrong, if someone could point me in the direction of my solution.

Upvotes: 0

Views: 148

Answers (2)

Daniel Kaplan
Daniel Kaplan

Reputation: 67484

This really doesn't have much to do with REST, this is a JPA question. The EntityManager's merge and persist will return a managed entity. It will have the id/key in it. Just return that in the @POST.

Upvotes: 2

user1395002
user1395002

Reputation: 11

Why can't you send a json object with the id filled in the response?

Upvotes: 0

Related Questions