简体   繁体   English

javax.persistence.Transient(@Transient)在更新时不适用于MongoDB

[英]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.

相关问题 指定字段对于 MongoDB 是暂时的,但对于 RestController 不是 - Specify field is transient for MongoDB but not for RestController springboot 与 MongoDb ,瞬态字段返回 null - springboot with MongoDb ,Transient field return null 在 Openshift 在线容器 4.2 上使用 mongodb + Nodejs 时出现瞬态错误 - Am getting Transient error while using mongodb + Nodejs on Openshift online container 4.2 带有 Kotlin 的 spring-data-mongodb 上的 @Transient 在读取期间导致异常 - @Transient on spring-data-mongodb with Kotlin results in exception during read 何时使用 Singleton vs Transient vs Request using Ninject and MongoDB - When to use Singleton vs Transient vs Request using Ninject and MongoDB 在Morphia中使用瞬态 - Using transient in Morphia Morphia:使用瞬态 - Morphia : Using Transient 从mongodb中读取对象后,如何实例化临时成员 - How do I instantiate transient members after an object is read from mongodb Hibernate OGM com Glasso上的MongoDB和JTA - javax.persistence.PersistenceException - Hibernate OGM com MongoDB and JTA on Glassfish - javax.persistence.PersistenceException Grails瞬态属性没有验证错误? - Grails transient property not validating error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM