0
import javax.persistence.*;

simple POJO
class A {

@Transient
protected transient someClass X;

}

Despite this, in the database, I still see it persisted? Any idea of this weird behavior?

Svetlin Zarev
  • 14,713
  • 4
  • 53
  • 82
rhozet
  • 542
  • 1
  • 6
  • 17

1 Answers1

0

It is because you mixed annotating both fields and getters. According to the JPA spec, you must remain consistent, in which you JPA annotate either only the fields, or only the getters. (usually JPA looks at the ID field and than decides to consider the fields or getters).

V G
  • 18,822
  • 6
  • 51
  • 89
  • Initially i had added annotaion only for field. It didnt work . If you see I have also made filed java transient. But it didnt work. When I added to getter/setters it worked..(i.e not got persisted.).Do you think getter/setters are more important than field for transient annotaion?? – rhozet Feb 10 '14 at 09:29
  • See these questions http://stackoverflow.com/questions/4188048/why-should-anybody-put-annotations-on-the-getters-or-setters-when-using-jpa-to-m http://stackoverflow.com/questions/594597/hibernate-annotations-which-is-better-field-or-property-access http://stackoverflow.com/questions/942035/hibernate-jpa-annotating-bean-methods-vs-fields – V G Feb 10 '14 at 09:32
  • Yes its solved..thanks. I am not sure of how to close it – rhozet Feb 10 '14 at 11:45