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.
javax.persistence.Transient (@Transient) is not working with MongoDB while updating
1.2k Views Asked by Parag Vaidya At
2
There are 2 best solutions below
0

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.
Use
@JsonIgnore
(from com.fasterxml.jackson.annotation).