Search code examples
mongodbpersistencespring-data

Spring Data MongoDB prevent persisting certain fields


I am using Spring Data for MongoDB to persist my domain objects. I was wondering if there is a way (perhaps with an Annotation?) to prevent Spring Data from persisting certain fields into MongoDB?

Does someone know how to do that or do I have to write my own Mapper?

Thanks.


Solution

  • In this case use the @Transient annotation for the field you need to ignore.

    Look more over here - Transient