@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!
答案 0 :(得分:13)
我认为您需要添加cascade
属性,以便JPA提供程序可以在添加到Blobx
的新blobs
上级联保留。目前,JPA提供程序无法通过错误消息报告。所以改变它(根据你的需要调整CascadeType
):
@OneToMany(cascade = CascadeType.ALL)
private List<Blobx> blobs;