0

I have created rest services using Spring MVC framework & in back end am using hibernate objects to fetch the data from the DB. I am directly exposing the hibernate objects through the rest service response as it is. But now i want to filter/dont want to show, some of the fields from the domain object in the rest service response. I want to know possible & performance effective solution for this. I have tried, JsonView, JsonFilter, @JsonIngore & created a POJO which will be populated from hibernate object & then will be shown in json response. Is there any other way? and are there any drawback of using JsonFilter? BTW i have implemented all these solutions in spring rest controller class (except the @jsonIgnore, I have added this annotation in hibernate object)

Are there any drawback of using jackson objectMapper class?

thanks in advance

user5402945
  • 165
  • 4
  • 11
  • I'm not clear with the question. Are things not working or do you want a better way of doing ? – Sashidhar Thallam Feb 24 '16 at 14:23
  • I am looking for better/alternate solution. When i did some research then i found that there are performance issue with JsonFilter. For some reason Jsonview is not working with Spring Hateoas. hence I am looking for any alternate solution – user5402945 Feb 24 '16 at 15:11
  • Try this: In your POJO (not the hibernate object) keep only those fields which you want to be part of the response and use this annotation @JsonIgnoreProperties(ignoreUnknown = true) at the class level for the POJO. Doing this ignores unknown properties. – Sashidhar Thallam Feb 24 '16 at 16:22
  • Thanks for your reply. I have tried that approach, but added the @JsonIgnoreProperties in the hibernate object. This works fine. I did that because as per my EA, we dont want to create additional layer (pojo) to achieve the result. I believe there are only these ways to filter json reponse - JsonView, JsonFilter, @JsonIngore/@JsonIgnoreProperties & POJO. Let me know if you have any other solution :) – user5402945 Feb 24 '16 at 16:50
  • Nothing I know at the moment. – Sashidhar Thallam Feb 25 '16 at 09:20

0 Answers0