I am asking because I would like to use code generation for the getters/setter.
And also because I would prefer the mapping annotations to appear at the top of the class, where I declare the fields.
I wonder if this approach is correct:
@Entity
@Table(name = "test")
// @Access(AccessType.PROPERTY) // cannot use this, because hibernate complains that no
public class Test implements Serializable
{
@Id
// I hope this results in property access for all of the other
// properties as well, but I am not sure how to confirm this...
@Access(AccessType.PROPERTY)
@Column(name = "id")
private long id = 0;
@Column(name = "test_string")
private String testString = null;
...
Update: I just tested the above example and it looks like the 'testString' property is accessed using field access. I added logging statements to the getter/setter and they were never called. On the other hand, when I added @Access(AccessType.PROPERTY) also to the 'testString' field, the getter and setter methods were called.
So at the moment it looks like my only option is to write "@Access(AccessType.PROPERTY)" in front of every field :-(