嗨我是Java持久性的新手。 我把註釋放在哪裏有關係嗎? 以下兩組代碼是否相同?Java持久性問題
非常感謝!
@Entity
@Table(name="user", schema="billing")
public class User {
private long id ;
private String userName ;
private String password ;
@Id
@GeneratedValue
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Column(name="password", length=20)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Column(name="user_name",length=15)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
對比:
@Entity
@Table(name="user", schema="billing")
public class User {
@Id
@GeneratedValue
private long id ;
@Column(name="user_name",length=15)
private String userName ;
@Column(name="password", length=20)
private String password ;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
可能重複[Hibernate/JPA - 註釋bean方法vs字段](http://stackoverflow.com/questions/942035/hibernate-jpa-annotating-bean-methods-vs-田) – 2010-06-07 20:38:39