Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is Field Access vs. Property Access in JPA ? please give example in detail

 
kish kumar
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is Field Access vs. Property Access in JPA ? please give example in detail
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA needs to access the data from your object to persist them. It can access the data in two ways, FIELD and PROPERTY access. FIELD access accesses the class fields (attributes/instance variables) directly, normally through reflection or byte code weaving. PROPERTY access accesses the data through calling a get/set method on your classes, also normally through reflection or byte code weaving.

For field access you annotate your class fields. For property access you annoate you get methods.

i.e.
@Basic
private String name;

or,
@Basic
public String getName() {
return this.name;
}
 
kish kumar
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the information
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic