hello! wanting to ask about a PR and possible new releases coming out. the PR is this one: crnk-project/crnk-framework#793. how does it look, is it okay?
how about plans for a new release? anything projected at the moment?
Hello there, I'm trying to make use of the @JsonApiMetaInformation, I followed the documentation but I don't see it in my response when I try it with the postman, here is the code of my resource:
/**
* The persistent class for the EF_V_API_TW_RUECKLIEF_KOPF_DET database table.
*
*
*/
@Data
@Entity
@NoArgsConstructor
@Table(name = "EF_V_API_TW_RUECKLIEF_KOPF_DET")
@JsonApiResource(type = "return", resourcePath = "returns")
public class Return implements Serializable {
private static final long serialVersionUID = 1L;
...
@JsonApiMetaInformation
private ReturnMeta meta;
public static class ReturnMeta implements MetaInformation, Serializable {
private static final long serialVersionUID = 8129518187692599777L;
private Boolean patchable = true;
public Boolean getPatchable() {
return patchable;
}
public void setPatchable(Boolean patchable) {
this.patchable = patchable;
}
}
Am I missing something in the repository?
Thank you very much.
GetFromOwnerStrategy
for the entity, the source actually is the JPA entity and the fieldAccessor call triggers JPA lazy loading.
Hi all,
i am trying to do a filter to check if a date value exists within a certain 2 ranges and using the below filter:
{"OR":{"AND":{"GE":{"transmissionDate":"2020-10-01T00:00"},"LE":{"transmissionDate":"2020-10-15T00:00"}},"AND":{"GE":{"transmissionDate":"2020-11-01T00:00"},"LE":{"transmissionDate":"2020-11-15T00:00"}}}}
I believe it is correct but crnk is only taking into consideration the last AND. Is this an issue?
@remmeier what would be the best option if you just want to add a prefix to outgoing links but not for matching requests?
Apparently setWebPathPrefix
is also used for matching and I only want this prefix to be present in response links.
Reimplementing JsonApiUrlBuilder
just to add a path prefix seems overkill too.
As ResourceRegistryImpl
is hardwired in CrnkBoot
I cannot override the getBaseUrl
either.
In the Doc it says: "setUrlMapper to provide a new url mapping implementation to customize how Crnk generates links." - But isn't that one use only for mapping incoming links? And UrlBuilder is used to generate links for resources?
@JochenReinhardt thanks very much for your input. achieved my intended result just as you said. leaving the result here just in case anyone encounters the same difficulty:
{"OR":[{"GE":{"transmissionDate":"2020-10-01T00:00"},"LE":{"transmissionDate":"2020-10-15T00:00"}},{"GE":{"transmissionDate":"2020-11-01T00:00"},"LE":{"transmissionDate":"2020-11-15T00:00"}}]}
%
as a literal part of a LIKE filter expression? For example: GET /tasks?filter[name][LIKE]=% 50% done
, where I'd like the first %
to act as a wildcard as usual and the second %
to act as an actual literal part of the expression, maybe somehow escaped. (In this case, Task 50% done
should match, while Task 50# done
shouldn't match)
Hi @remmeier. In a relationship where the source and target are both of the same type, while filtering/sorting/pagination how do you refer to just the target only since in a filter you are to specify the type.
E.g. a resource of a type person having a relationship "children" which is of type person as well. How can I get the persons together with the eldest child younger than 18?
/persons?include=children?filter[children][age][LT]=18&sort=-children.age&page[limit]=1
Hi @remmeier I want to remove the foreign key constraint but to keep the relation between objects but without having a constraint
so If we have a parent object which has a list of childs
I want to easily link a non existent parent to a child object
this is can be done using jpa only in spring boot using this annotation @org.hibernate.annotations.ForeignKey(name = "none") but with crnk it returns like this when doing a post
"errors": [
{
"status": "404",
"code": "NOT_FOUND",
"detail": "type=parent, ids=[2972b858-8f77-4462-89bb-7a406e248f46]",
"source": {
"pointer": ""
},
"meta": {
"type": "NOT_FOUND",
"resourceType": "child"
}
}
]
}
Parent class
@Data
@JsonApiResource(type = "parent", resourcePath = "parents")
@Entity
@Table(name = "parents")
public class Parent {
@Id
@JsonApiId
private UUID id;
private String name;
@JsonApiRelation(opposite = "parent",
lookUp = LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL,
repositoryBehavior = RelationshipRepositoryBehavior.FORWARD_OPPOSITE)
@OneToMany(mappedBy = "parent")
@org.hibernate.annotations.ForeignKey(name = "none")
private List<Child> childs;
}
Child Class
@Data
@JsonApiResource(type = "child", resourcePath = "childs")
@Entity
@Table(name = "childs")
public class Child {
@Id
@JsonApiId
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "id", updatable = false, nullable = false)
private UUID id;
@JsonApiRelationId
@Column(name = "parent_id")
private UUID parentId;
private String type;
@JsonApiRelation(idField = "parentId", opposite = "childs",
lookUp = LookupIncludeBehavior.AUTOMATICALLY_WHEN_NULL,
repositoryBehavior = RelationshipRepositoryBehavior.FORWARD_OWNER,
serialize = SerializeType.EAGER)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_id", insertable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "none")
private Parent parent;
public void setParentId(UUID parentId) {
this.parentId = parentId;
this.parent = null;
}
public void setParent(Parent parent) {
this.parent = parent;
this.parentId = parent != null ? parent.getId() : null;
}}