Skip to content
Advertisement

Composite object not showing up in the response – Spring Boot

So I’m getting some roles introduced in my system. I have a class that looks like this :

JavaScript

The classes that are mapping by this look like as follows :

JavaScript

The user class looks like :

JavaScript

For an initial POC , i wrote a simple API method that looks like :

JavaScript

Here, I expect to get the User object which also has a Set as well as one userRoleMapping object under the Role_info key.

My actual output looks like :

JavaScript

My Role_Info is populated. However, The userRoles within the user object isn’t. First, I want the inner Set of userRoles to be populated. Second,I also don’t want the Role_Info to include the entire User object, how do I achieve this?

Advertisement

Answer

  1. If i am not wrong, please try changing your mapping

    JavaScript

To:

JavaScript
  1. To exclude the field/object, i am using @JsonIgnore:

    JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement