Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Problems with cascade delete doing update instead
Problems with cascade delete doing update instead [message #835105] Mon, 02 April 2012 16:10 Go to previous message
Dave Brosius is currently offline Dave Brosius
Messages: 11
Registered: July 2009
Junior 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?





 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic:"cannot be cast" error in Weblogic server 10.3.5
Next Topic:JPA ManyToMany in case of users and groups?
Goto Forum:
  


Current Time: Tue May 21 09:50:44 EDT 2013

Powered by FUDForum. Page generated in 0.01719 seconds