What are (if there are) the best practices for returning objects on CRUD operations. In my case, for Java.
For example, for CREATE I supose to return the object, its ID…?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
create – created object. I know, I know it’s typically the same object, but it’s both convenient and elegant.
update – also return the same object. In some frameworks like JPA updated object can be a different instance then the one provided.
restore – obviously the object you want to restore. If you are restoring a list, consider implementing paging – taking offset/max and returning list wrapped in a
Pageobject with some extra metadata like the total number of entries.delete – there is nothing to return here,
void.