jpa-Primarykey relationship
Hi created student entity in gogole app engine datastore using JPA.
Student--->Coding
@Entity
@Table(name="StudentPersonalDetails", schema="PUBLIC")
public class StudentPersonalDetails {
@Id
@Column(name = "STUDENTNO")
private Long stuno;
@Basic
@Column(name = "STUDENTNAME")
private String stuname;
public void setStuname(String stuname) {
this.stuname = stuname;
}
public String getStuname() {
开发者_JAVA技巧return stuname;
}
public void setStuno(Longstuno) {
this.stuno = stuno; }
public Long getStuno() {
return stuno; }
public StudentPersonalDetails(Long stuno,String stuname) { this.stuno = stuno; this.stuname = stuname; }
}
I stored Property value as follows
Stuno Stuname
1 a
2 b
If i stored Again Stuno No 1 stuname z means it wont allow to insert the record But. It Overwrite the value
Stuno Stuname
1 z
2 b
How to solve this?
How to solve what? stuno is annotated with Id, you can't insert two entities with the same stuno. And if you modify an entity that already has a representation in the data sotre (i.e. an entity that has a persistent identity), it will get updated. Honestly, I don't get the problem or what result you expect.
加载中,请稍侯......
精彩评论