简体   繁体   中英

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

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 . Currently, the JPA provider can't, as reported by the error message. So change it like this (adapt the CascadeType to match your needs):

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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