Is there a way to keep LAZY loading and deserializing an object using an identifier instead of a POJO object.
I have 2 classes that are connected by a many-to-many relationship.
Something like that
public class User { @Id @JsonProperty public long id; @ManyToMany( fetch = FetchType.EAGER, ) @JoinTable( name = "User_EntityType", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "type_id") ) @JsonProperty public Set<Type> types; } public class Type { @Id @JsonProperty public long id; @ManyToMany( fetch = FetchType.EAGER, mappedBy = "types", targetEntity = User.class ) @JsonProperty public Set<User> users; }
The data type is working fine. I can write and read using sleep mode without any problems.
However, I want to return the User object using the REST API, so I use Jackson to deserialize. The problem is, when I do this, it deserializes each Type in the User object, which includes other type objects, and creates a huge mess.
Is it possible instead to simply return the identifiers of the Set of Long type instead of the Set of Type?
user1744206
source share