The part of the JPA specification published by Pascal Thivent seems rather confusing. In fact, Hibernate respects transient when accessing a field is used, but ignores it when accessing properties. Perhaps this is Hibernate-specific behavior.
For example, in this case bar not serialized, but stored in the database:
@Entity @Access(AccessType.FIELD) // Default access type - field public class Foo { @Id @GeneratedValue private Long id; transient private String bar; ... @Access(AccessType.PROPERTY) // Override default access type for this property public String getBar() { return bar; } }
EDIT:. Since it is unclear how this behavior complies with the JPA specification, it might be best to use different names for the transient field and the corresponding property.
axtavt
source share