It should be a simple thing! But so far I could not find the answer. Either I'm missing something obvious, or I'm missing something obvious ...
I have a class, say Personality. With three fields - "id", "name" and "reputation". Let's say that I'm ready to accept updates for the "name", but not for the "reputation." I would like Spring Data to retrieve the βreputationβ value when retrieving from the database, but ignore it when I save the bean.
There is @Transient annotation, but then Spring completely ignores the field and does not fill it at all. Ideally, I'm looking for something like @ReadOnly annotations.
More details
- I use Spring Data for Neo4j, but I believe this applies to any flavor of Spring data.
- This is the backend for the RESTful service in Jersey / Jackson. ** When I satisfy the GET request, I would like to use the value "reputation". But when I receive the PUT update, I do not want to receive it. ** So far, I have been able to use Jackson's features. But I would like to be able to update the database without first using the Person object.
- The only way I can count on this work is to define two classes: one with the reputation field and one without it. But that seems really awkward. Isnβt it easier?
source
share