Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@RestResource( exported=false ) ignored

as in title - my @RestResource(exported=false) is ignored on field. Spring data rest still want to make json from it, I would like to simply skip it for now, as changing rel in WorkflowEvent gave me nothing..

 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "submission")
@OrderBy("date desc")
@RestResource(exported = false)
private List<WorkflowEvent> events = new ArrayList<WorkflowEvent>();

I get:

{"timestamp":1410850806347,"status":500,"error":"Internal Server Error","exception":"org.springframework.http.converter.HttpMessageNotWritableException","message":"Could not write JSON: Detected multiple association links with same relation type! Disambiguate association @javax.persistence.JoinColumn(insertable=true, unique=false, referencedColumnName=, columnDefinition=, name=submission_id, updatable=true, nullable=true, table=, [email protected](name=, value=CONSTRAINT, foreignKeyDefinition=)) @javax.persistence.ManyToOne(fetch=EAGER, cascade=[], optional=true, targetEntity=void) @org.springframework.data.rest.core.annotation.RestResource(description=@org.springframework.data.rest.core.annotation.Description(value=), path=, exported=false, rel=) private mypackage.MyClass mypackage.WorkflowEvent.myclass using @RestResource!; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Detected multiple association links with same relation*

ofcourse it works when I comment this field.

My versions:

\- org.springframework.data:spring-data-rest-webmvc:jar:2.1.4.RELEASE:compile
[INFO] |     \- org.springframework.data:spring-data-rest-core:jar:2.1.4.RELEASE:compile
[INFO] |        +- org.springframework.hateoas:spring-hateoas:jar:0.16.0.RELEASE:compile
like image 729
hi_my_name_is Avatar asked Sep 16 '14 07:09

hi_my_name_is


1 Answers

@RestResources is only supported on domain properties that point to managed resources. Thus, if you don't expose WorkflowEvent by a Spring Data REST managed repository, the annotation has no effect whatsoever. In this case, simply use an @JsonIgnore to let Jackson not render the property.

like image 101
Oliver Drotbohm Avatar answered Sep 23 '22 01:09

Oliver Drotbohm