简体   繁体   中英

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.
I am using Play2.2, mongo-java-driver, MongoJack and MongoDB for my application.
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.

But this one, which is a JPA annotation, will not work for Spring Data's MongoDB:

import javax.persistence.Transient;

Which is part of the Java Persistence API .

使用@JsonIgnore (来自com.fasterxml.jackson.annotation)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM