You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi.
We have found a minor bug with crnk relationship. In a relationship the type specifies which repository to fetch the data from. But in our case the model of repository is a subclass of the object used in the model of the request.
here both "cat" and "dog" are subclasses of "animal". The ID is for dog. Human have @JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_ALWAYS) private Animal animal;
it will fail for "cat" as the repository of "dog" will throw "ResourceNotFound". The bug is that if the ID of said object from repository doesn't match the type specified on the relationship but both of them are subclasses in what they are trying to populate.
Shouldn't the relationship type match the object jsonapiresource type? { "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "animal", "id": "123" } },"pet": { "data": { "type": "animal", "id": "123" } } } } }
As this is what is specify in Human class?
Thanks,
Chris
The text was updated successfully, but these errors were encountered:
hi, do you have an exception? not yet sure at what point it fails, but inheritance is in general sipported. the example abobe repeats the pet relationship, i guess that is an error in that snippet? it is good that the relationship data section lists the subtypes rather than animal as type. that allows to quickly determine its actual type.
Hi.
We have found a minor bug with crnk relationship. In a relationship the type specifies which repository to fetch the data from. But in our case the model of repository is a subclass of the object used in the model of the request.
Example:
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "dog", "id": "123" } },"pet": { "data": { "type": "cat", "id": "123" } } } } }
here both "cat" and "dog" are subclasses of "animal". The ID is for dog. Human have
@JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_ALWAYS) private Animal animal;
it will fail for "cat" as the repository of "dog" will throw "ResourceNotFound". The bug is that if the ID of said object from repository doesn't match the type specified on the relationship but both of them are subclasses in what they are trying to populate.
Shouldn't the relationship type match the object jsonapiresource type?
{ "data": { "type": "human", "attributes": { "name": "Jon Smith" }, "relationships": { "pet": { "data": { "type": "animal", "id": "123" } },"pet": { "data": { "type": "animal", "id": "123" } } } } }
As this is what is specify in Human class?
Thanks,
Chris
The text was updated successfully, but these errors were encountered: