Annotations: methods vs variables
- by Zenzen
I was always sure (don't know why) that it's better to add annotations to variables, but while browsing the Hibernate doc http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-hibspec-collection I noticed they tend to annotate the methods. So should I put my annotations before methods, like this:
@Entity
public class Flight implements Serializable {
private long id;
@Id @GeneratedValue
public long getId() { return id; }
public void setId(long id) { this.id = id; }
}
Or is it better to do it like this:
@Entity
public class Flight implements Serializable {
@Id @GeneratedValue
private long id;
public long getId() { return id; }
public void setId(long id) { this.id = id; }
}
Or maybe there's no difference?