I was searching the whole day on this topic, and checked almost all the submitted questions about it.
Here is my problem: It was supposed for me to be a straightforward task to make Jackson respect the the lazy attributes defined in hibernate. But as I noticed, there seems to be no solution for this problem that I think is faced by almost everyone who develop a restful java spring application and depend on Json responses from the server. The Json response contains serialized objects that most of the times should not contains the other related objects (that are always fetched by Jackson which cause no needed sql queries and additional not necessary loading time).
Even the jackson datatype hibernate library only provide a solution to prevent the serialization exception thrown when Jackson try to serialize the lazy not loaded attributes, without actually restricting the serialization to only the fetched attributes. In addition, using the JsonIgnore annotation does not resolve the problem because it prevent Jackson even from serializing the fetched/eager attributes forever.
Does someone know a solution for this problem? If no, I just want to know please what method is generally used to just let the server respond with the same loaded objects in a json format without changing anything else?
EDIT:
Sorry for not providing actual code, my situation exactly fit the question in jackson - do not serialize lazy objects. Since there is no solution on that question, I am highlighting on that problem to make sure if there is a solution for it, or otherwise what is the approach used in this case other than using Jackson to send to objects as response in JSON format.
Thanks