I am currently learning Hibernate and the Java Persistence API.
I have an @Entity class, and need to apply annotations to the various fields. I have included in the code
You have to put annotations only for field or only for getter
@Id
@Column(name="id", unique=true, nullable=false)
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
or
private int id;
@Id
@Column(name="id", unique=true, nullable=false)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
And for all fields/properties in same way. All annotations for fields or all annotations for getter