我正在尝试使用 JPA 在应用引擎数据存储中插入一个新实体。我收到以下错误。有人可以建议什么可能是错的。
java.lang.IllegalArgumentException: id cannot be zero
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:52)
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:47)
at com.google.appengine.api.datastore.KeyFactory.createKey(KeyFactory.java:35)
at com.google.appengine.datanucleus.EntityUtils.intOrLongToInternalKey(EntityUtils.java:381)
at com.google.appengine.datanucleus.EntityUtils.idToInternalKey(EntityUtils.java:220)
at com.google.appengine.datanucleus.EntityUtils.idToInternalKey(EntityUtils.java:208)
at com.google.appengine.datanucleus.DatastoreIdentityKeyTranslator.getKey(DatastoreIdentityKeyTranslator.java:32)
这是我的实体类
//imports
@Entity
public class QuizTable {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
private String quizName;
private String quizContent;
public QuizTable(){}
public Long getId() {return id;}
public String getQuizName() {return quizName;}
public String getQuizContent() {return quizContent;}
public void setId(Long id) { this.id = id;}
public void setQuizName(String quizName) {this.quizName=quizName;}
public void setQuizContent(String quizContent) {this.quizContent=quizContent;}
}