0

I am coding a jax-rs webservice for a project. I use JPA in order to access the database. Now I want to split the webservice into front- and backend.

When I now create a select query and return an entity I want some properties that a frontend user must not see not to be included in the response, but I want those properties being sent when a request is being sent to the backend service.

Thanks for your help.

luko0610
  • 11
  • 6
  • You haven't asked any question. You apparently haven't tried anything either. – JB Nizet Sep 30 '17 at 18:41
  • I have tried using transient, but like that i cannot exclude different properties depending on which properties i want to deliver. – luko0610 Sep 30 '17 at 18:45
  • You need to either use Jackson views (assuming your JAX-RS provider uses Jackson and it's possible to make it use views), or return different DTO objects depending on the recipient. In my experience, returning JPA entities from a REST service is almost always a bad idea. – JB Nizet Sep 30 '17 at 18:47
  • Thanks for your help. I'll have a look at Jackson now. – luko0610 Sep 30 '17 at 18:52
  • Possible duplicate of [Serialize one class in two different ways with Jackson](https://stackoverflow.com/questions/12141561/serialize-one-class-in-two-different-ways-with-jackson) – luko0610 Sep 30 '17 at 19:49

0 Answers0