无法在app引擎中保留jpa实体

Bun*_*bit 7 java google-app-engine jpa

   @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 
}
Run Code Online (Sandbox Code Playgroud)

在持续上述我遇到的Userx实体对象的同时

java.lang.IllegalStateException: Field "entities.Userx.blobs" contains a persistable object that isnt persistent, but the field doesnt allow cascade-persist!
Run Code Online (Sandbox Code Playgroud)

Pas*_*ent 13

我认为你需要添加一个cascade属性,以便JPA提供程序可以级联持久保存在Blobx添加到的新的blobs.目前,JPA提供程序无法通过错误消息报告.所以改变它(根据CascadeType你的需要调整):

@OneToMany(cascade = CascadeType.ALL)    
private List<Blobx> blobs;
Run Code Online (Sandbox Code Playgroud)