title: How to set readOnly on property using Spring Data Rest and MongoRepository?
body: <p>I would like to do something like this: <a href="http://www.davismol.net/2015/03/21/jackson-using-jsonignore-and-jsonproperty-annotations-to-exclude-a-property-only-from-json-deserialization/" rel="nofollow">http://www.davismol.net/2015/03/21/jackson-using-jsonignore-and-jsonproperty-annotations-to-exclude-a-property-only-from-json-deserialization/</a> - but this method doesn't work in Spring Data Rest.</p>
  
  <p>I know that there is a annotation @ReadOnlyProperty and that would be the best solution to use it, because it is reflected in the JSON Schema response:</p>
  
  <pre><code>{
    "title" : "org.example.Person", 
    "properties" : { 
      "firstName" : {
        "readOnly" : true,
        "type" : "string"
      },
      ..
  </code></pre>
  
  <p>but in this way annotated property is not returned by the GET operation (it has null value).</p>
  
  <p><strong>Update 1</strong>: adding code sample</p>
  
  <pre><code>@Getter
  @Document
  public class Person {
      @Id
      private String id;
      private String firstName;
      private String lastName;
      @ReadOnlyProperty
      private String comments;
  }
  
  @RepositoryRestResource
  public interface PersonRepository extends MongoRepository&lt;Person, String&gt; {
  
  }
  </code></pre>
  
  <p><strong>Update 2</strong>: thanks to the suggestions of Leon, I found a mistake in my reasoning - method using annotations @JsonIgnore and @JsonProperty was working properly, but also was blocking the provisioning database with test data - which is why the operation GET was showing earlier null value for comments field.</p>