开发者

jpa-Primarykey relationship

开发者 https://www.devze.com 2023-01-02 21:52 出处:网络
Hi created student entity in gogole app engine datastore using JPA. Student--->Coding @Entity @Table(name=\"StudentPersonalDetails\", schema=\"PUBLIC\")

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消