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

时间:2010-04-13 09:00:53

标签: 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 
}

在持续上述Userx实体对象时遇到了

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

1 个答案:

答案 0 :(得分:13)

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

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