简体   繁体   English

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

[英]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 
}

while persiting the above Userx entity object i am encountering 在持续我遇到的上述Userx实体对象时

java.lang.IllegalStateException: Field "entities.Userx.blobs" contains a persistable object that isnt persistent, but the field doesnt allow cascade-persist!

I think you need to add a cascade attribute so that the JPA provider can cascade persist on the new Blobx added to the blobs . 我认为你需要添加一个cascade属性,以便JPA提供程序可以在添加到blobs的新Blobx持久化。 Currently, the JPA provider can't, as reported by the error message. 目前,JPA提供程序无法通过错误消息报告。 So change it like this (adapt the CascadeType to match your needs): 所以改变它(调整CascadeType以满足您的需求):

@OneToMany(cascade = CascadeType.ALL)    
private List<Blobx> blobs;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM