Hi,
I have a problem with JPA and (cascade={CascadeType.ALL}, orphan Removal=real). I have a project that can have some comments and some configurations. The configurations can has some comments, too.
- If I add a comment to the project which has a configuration, then I got the followed error.
- If I add a comment to the project that has no configurations, then it works well.
- If I add a comment to a configuration, that works also well.
- If I remove (cascade={CascadeType.ALL}, orphanRemoval=true) from the private List ; on the Configuration.java Entity, then all scenarios works well without errors. But, I have a Comment corps in the DataBase, if I delete some configurations.
I can't see the problem, how it does not work with cascade.
ErrorMessage:
Developer Console:
Type: DSRequest
DS or appID: project_DataSource
Operation: Update
Component: isc_DynamicForm
Status: -10
DSRequest
Response Raw
I have a problem with JPA and (cascade={CascadeType.ALL}, orphan Removal=real). I have a project that can have some comments and some configurations. The configurations can has some comments, too.
- If I add a comment to the project which has a configuration, then I got the followed error.
- If I add a comment to the project that has no configurations, then it works well.
- If I add a comment to a configuration, that works also well.
- If I remove (cascade={CascadeType.ALL}, orphanRemoval=true) from the private List ; on the Configuration.java Entity, then all scenarios works well without errors. But, I have a Comment corps in the DataBase, if I delete some configurations.
I can't see the problem, how it does not work with cascade.
ErrorMessage:
Code:
=== 2012-06-28 20:12:35,843 [l0-6] WARN DataSource - [builtinApplication.project_DataSource_update] Couldn't set property 'comment' for datasource 'project_DataSource'. Actual error: javax.persistence.PersistenceException: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: com.detection.smiths.eapcfg.server.persistence.Cfg.comment === 2012-06-28 20:12:35,851 [l0-6] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2012-06-28 20:12:35,852 [l0-6] DEBUG JPADataSource - Committing transaction for 1 queued operation(s). === 2012-06-28 20:12:35,852 [l0-6] ERROR JPADataSource - Failed to commit transaction. Rolling back. javax.persistence.RollbackException: Transaction marked as rollbackOnly
Type: DSRequest
DS or appID: project_DataSource
Operation: Update
Component: isc_DynamicForm
Status: -10
DSRequest
Code:
{ "dataSource":"project_DataSource", "operationType":"update", "componentId":"isc_DynamicForm_1", "data":{ "cfg":[ { "comment":[ ], "todo":"CFG" } ], "comment":[ { "comment":"12121212" } ], "projectName":"NEW PROJECT", "status":"OPEN" }, "callback":{ "target":[DynamicForm ID:isc_DynamicForm_1], "methodName":"saveEditorReply" }, "showPrompt":true, "prompt":"Saving form...", "oldValues":{ "cfg":[ { "comment":[ ], "todo":"CFG" } ], "comment":[ { "comment":"12121212" } ], "projectName":"NEW PROJECT", "status":"OPEN" }, "clientContext":{ }, "requestId":"project_DataSource$6277" }
Code:
[ { data:{ cfg:[ { comment:[ ], todo:"CFG" } ], comment:[ ], projectName:"NEW PROJECT", status:"OPEN" }, invalidateCache:false, isDSResponse:true, operationType:"update", queueStatus:-1, status:-10 } ]
Code:
@Entity @Table (name="Cfg") public class Cfg implements Serializable{ @Id @Column @GeneratedValue (strategy = GenerationType.IDENTITY) private Long cfgId; @Column (nullable = false) private String todo; @OneToMany(cascade={CascadeType.ALL}, orphanRemoval=true) @JoinColumn(name="cfgCommentId", referencedColumnName="cfgId") private List<Comment> comment; ... }
Code:
@Entity @Table (name="Project") public class Project implements Serializable{ @Id @Column @GeneratedValue (strategy = GenerationType.IDENTITY) private Long nodeId; @Column (nullable = false) private String projectName; @OneToMany(cascade={CascadeType.ALL}, orphanRemoval=true) @JoinColumn(name="projectCommentId", referencedColumnName="nodeId") private List<Comment> comment; ... }
Code:
@Entity @Table (name="Comment") public class Comment implements Serializable{ @Id @Column @GeneratedValue (strategy = GenerationType.IDENTITY) private Long commentId; @Column private String comment=""; @Column private Boolean ok; public Comment (){ } ... }
Code:
<DataSource ID="project_DataSource" serverConstructor="com.isomorphic.jpa.JPADataSource" beanClassName="com.detection.smiths.eapcfg.server.persistence.Project" > <fields> ... <field name="comment" type="comment_DataSource" foreignKey="comment_DataSource.commentId" multiple="true" title="Kommentar" required="false"/> <field name="cfg" type="cfg_DataSource" foreignKey="cfg_DataSource.cfgId" multiple="true" title="Cfg" required="false"/> </fields>
Code:
<DataSource ID="cfg_DataSource" serverConstructor="com.isomorphic.jpa.JPADataSource" beanClassName="com.detection.smiths.eapcfg.server.persistence.Cfg" > <fields> ... <field name="comment" type="comment_DataSource" foreignKey="comment_DataSource.commentId" multiple="true" title="Kommentar" required="false"/> </fields> </DataSource>