Problems with cascade delete doing update instead [message #835105] |
Mon, 02 April 2012 20:10 |
Dave Brosius Messages: 34 Registered: July 2009 |
Member |
|
|
I have a one to many relationship between a parent (workflow) and children (stage). In the database i have a delete constraint such that deletes on workflow delete stage. This works fine from sqlplus.
class Workflow {
@Override
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "workflow", targetEntity = Stage.class)
@JoinColumn(name = "WORKFLOW_ID")
public Set<Stage> getStages() {
return m_stages;
}
}
class Stage {
@Override
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false, targetEntity = Workflow.class)
@JoinColumn(name = "WORKFLOW_ID", nullable = false)
public Workflow getWorkflow() {
return m_workflow;
}
}
when i load the workflow by name inside a @Transactional(propagation = Propagation.REQUIRED) method and then em.remove(workflow) that object,
I get exceptions, such as
Error Code: 1407
Call: UPDATE STAGES SET WORKFLOW_ID = ?, FAILURE_STAGE_ID = ?, SUCCESS_STAGE_ID = ? WHERE (STAGE_ID = ?)
bind => [4 parameters bound]
Caused by: java.sql.SQLException: ORA-01407: cannot update ("AVONDALE"."STAGES"."WORKFLOW_ID") to NULL
because I have defined the stages.workflow_id column to be not nullable.
Why is eclipselink trying to update the stages table with null workflow ids, rather than just deleting the stage row itself? How do i fix that?
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02078 seconds