views:

17

answers:

1

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() {

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?

A: 

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.

Pascal Thivent
If i entered stuno already exist i will get updated ,I want the i will not update
@megala: 1) I think that I gave you a valid hint in my answer. 2) With the current level of details of your question, I can't add anything.
Pascal Thivent