What is the use of field based access? if we can only update fields from Entity itself.
Good question. Actually, in most cases the spec will force you to write setter and getter methods.
Just having @Column annotation makes entity as Field based access?
No. "Field based" means that @Id is used on field level (in accordance other annotations like @Column must be used on field level, too). "Propertiy based" access means that @Id is used on the getter method of the corresponding field (in accordance other annotations like @Column must be used on getter methods, too). Example:
- Field based access:
@Id
private long id;
- Property based access:
private int id;
...
@Id
public int getId(){ return id; }
"Access" describes here the way how the persistence provider accesses the instance variables: If you use field based access, the persistence provider will assign an object/value (that it retieved from a
jdbc call) directly to the instance variable. Setter methods are ignored by the persistence provider in this case.
If you use property based access the persistence provider will call the corresponding setter method (the parameter would be the object/value that the persistence provider retrieved from a jdbc call).
One last remark: @Column without specifying any field of the annotation doesn't have an effect.
[ November 26, 2008: Message edited by: Ralph Jaus ]