@RestResource (exported = false) is ignored

as in the header - my @RestResource (exported = false) is ignored in the field. Spring, the rest of the data still wants to make json out of it, I would just skip it now, since changing the rel in WorkflowEvent has given 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=, foreignKey=@javax.persistence.ForeignKey (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.Descr iption(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* 

Of course, it works when I comment on 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 
+6
source share
1 answer

@RestResources is only supported for domain properties that point to managed resources. Thus, if you do not expose WorkflowEvent managing manager of the Spring Data REST repository, the annotation has no effect. In this case, just use @JsonIgnore to let Jackson not display the property.

+11
source

Source: https://habr.com/ru/post/975343/


All Articles