[英]can't persist jpa entity in app engine
@Entity
public class Blobx {
private String name;
private BlobKey blobKey;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
//getters and setters
}
@Entity
public class Userx {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key id;
private String name;
@OneToMany
private List<Blobx> blobs;
//getters and setters
}
在持續我遇到的上述Userx實體對象時
java.lang.IllegalStateException: Field "entities.Userx.blobs" contains a persistable object that isnt persistent, but the field doesnt allow cascade-persist!
我認為你需要添加一個cascade
屬性,以便JPA提供程序可以在添加到blobs
的新Blobx
持久化。 目前,JPA提供程序無法通過錯誤消息報告。 所以改變它(調整CascadeType
以滿足您的需求):
@OneToMany(cascade = CascadeType.ALL)
private List<Blobx> blobs;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.