I am not familiar with Spring Rest Data, but as far as I can tell, it uses Jackson to handle JSON.
If this is true, I would suggest that your situation requires the use of mixing annotations , which are designed to control the serialization of classes that cannot be changed.
First create a simple blending class with a set of JsonIgnoreType annotations.
@JsonIgnoreType public class OmitType {}
Next, register the mix-in in your instance of ObjectMapper . As far as I can tell, you are accessing it in Spring Rest Data by following these instructions :
To add Jackson's own configuration to ObjectMapper used by Spring Data REST, override the configureJacksonObjectMapper method. This method will be passed to ObjectMapper [...]
In the configureJacksonObjectMapper method, register a mix with an unwanted type, like this:
objectmapper.addMixIn(RelTargetType.class, OmitType.class);
Please note that RelTargetType.class is just a guess. Change the type that the field actually contains. This should force Jackson to ignore fields of this particular type whenever he encounters them.
Added:
In case the relTargetType field in MyContentEntity is actually just a string field, you can replace the mix with the following:
public abstract class OmitType { @JsonIgnore public abstract String getRelTargetType(); }
And register it should be changed to:
objectmapper.addMixIn(MyContentEntity.class, OmitType.class);