1


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.

Parag Vaidya
  • 81
  • 1
  • 7

2 Answers2

2

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.

Jeach
  • 8,656
  • 7
  • 45
  • 58
0

Use @JsonIgnore (from com.fasterxml.jackson.annotation).

Lukasz Wiktor
  • 19,644
  • 5
  • 69
  • 82