What is difference between @JsonApiRelationId and @JsonApiRelation?

165 Views Asked by At

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

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

1

There are 1 best solutions below

2
dgebert On BEST ANSWER

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;