Mongo - Ignore property from being persisted

后端 未结 3 1907
面向向阳花
面向向阳花 2020-12-18 17:45

I have a standard POJO that has a set of properties in it. The POJO has been annotated as a @Document, so as to be persisted in MongoDB as a Document.

H

相关标签:
3条回答
  • 2020-12-18 18:00

    In case you are looking for the actual package like I was, this one will work:

    import org.springframework.data.annotation.Transient;
    

    Which is from the Spring framework API documentation.

    But this one, which is a JPA annotation, will not work for MongoDB:

    import javax.persistence.Transient;
    

    Which is part of the Java Persistence API.

    0 讨论(0)
  • 2020-12-18 18:09

    The @Transient annotation it is. See http://static.springsource.org/spring-data/data-document/docs/current/reference/html/#mapping-usage-annotations

    0 讨论(0)
  • 2020-12-18 18:21

    use @Transient be aware that you use the below package

    import org.springframework.data.annotation.Transient;
    
    0 讨论(0)
提交回复
热议问题