How to get json response only with an id of the related entity


Fetching entities with complex relationships can consume a lot of resources during calls to your API. To minimize the size of the requested json string, you can use the LAZY fetch type. This will result in accessing only the serialized object and its properties – without considering its relations. But often you need to obtain the identifiers of the associated objects as well. Check out how to fetch an entity with an id of a related object while preserving proper serialization and deserialization.