[英]javax.persistence.Transient (@Transient) is not working with MongoDB while updating
I am trying to use @Transient (javax.persistence.Transient) in one of my entity, it works fine for inserting the records (the Transient fields are not stored in DB which is OK) but when I am trying to update the same entity the Transient fields also gets stored into mongodb. 我正在尝试在我的一个实体中使用@Transient (javax.persistence.Transient),它可以很好地插入记录(Transient字段未存储在DB中,这是可以的),但是当我尝试更新同一实体时瞬态字段也将存储到mongodb中。
I am using Play2.2, mongo-java-driver, MongoJack and MongoDB for my application. 我正在为我的应用程序使用Play2.2,mongo-java-driver,MongoJack和MongoDB。
Please help me. 请帮我。 Thanks in advance.
提前致谢。
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. 这来自Spring框架API文档。
But this one, which is a JPA annotation, will not work for Spring Data's MongoDB: 但是,这是一个JPA批注,不适用于Spring Data的MongoDB:
import javax.persistence.Transient;
Which is part of the Java Persistence API . 这是Java Persistence API的一部分 。
使用@JsonIgnore
(来自com.fasterxml.jackson.annotation)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.