Search code examples
javajpacrnk

What is difference between @JsonApiRelationId and @JsonApiRelation?


https://www.crnk.io/releases/stable/documentation/#_jsonapirelation

What is the need of @JsonApiRelationId as I see no difference without using it?


Solution

  • You can use @JsonApiRelationId instead of @JsonApiRelation when you just need to perate on ID, not on the entire related resource, or when the id of related resource can be obtain much cheaper then full resource.

    Both could look like this:

    public class Car {
      ...
    
      @JsonApiRelationId
      private Long ownerId;
    
      @JsonApiRelation
      private Person owner;