Hibernate/JPA - annotating bean methods vs fields
- by Benju
I have a simple question about usage of Hibernate. I keep seeing people using JPA annotations in one of two ways by annotating the fields of a class and also by annotating the get method on the corresponding beans.
My question is as follows: Is there a difference between annotating fields and bean methods with JPA annoations such as @Id.
example:
@Entity
public class User
{
**@ID**
private int id;
public int getId(){
return this.id;
}
public void setId(int id){
this.id=id;
}
}
-----------OR-----------
@Entity
public class User
{
private int id;
**@ID**
public int getId(){
return this.id;
}
public void setId(int id){
this.id=id;
}
}