Annotations: methods vs variables

Posted by Zenzen on Stack Overflow See other posts from Stack Overflow or by Zenzen
Published on 2010-05-19T20:24:42Z Indexed on 2010/05/19 20:40 UTC
Read the original article Hit count: 196

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about j2ee