Reputation: 186
I'm trying to avoid showing a couple fields in the content of the JSON response using spring-data-rest. The annotation @RestResource(exported = false) is not working for a property in an Entity class. It could be a similar issue to the one reported in: Property reference mapping in Spring Data Rest 2.0.0
In my case I have the next two properties:
@RestResource(exported = false)
private byte[] image;
@RestResource(exported = false)
private Date updateTime;
The annotation is not working. I also tried the next approach without success:
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setResourceMappingForDomainType(MyClass.class)
.addResourceMappingFor("updateTime")
.setExported(false);
}
Looking at the spring-data-rest current code in github makes me think that any metadata (annotation) to set the content for the JSON objects is never used. I appreciate your help with this issue. Maybe is there a different way to do it in the current 2.0.0 versions?
Upvotes: 2
Views: 2750
Reputation: 624
It should be fixed in the next release as this issue report says.
Upvotes: 1
Reputation: 3244
If you are using latests snapshot the following should work
@JsonIgnore
private byte[] image;
@JsonIgnore
private Date updateTime;
By the way, @RestResource is a class and method annotation and is tell SDR if you like to expose those classes or methods through SDR
For controlling serialization of domain object use jackson annotation @JsonIgnore
Upvotes: 1