Skip to main content

@OnetoMany in JPA: Problem with remove/delete

2 replies [Last post]
dinesh_kb
Offline
Joined: 2008-07-29

Hi,

I am having two entities which are related with @OnetoMany and @JoinTable.
It is a uni-directional mapping with JoinTable and JoinColumn. I am facing the problem while removing the data from DAOclass which states as follows.

Internal Exception: java.sql.SQLException: ORA-02292: integrity constraint violated - child record found

The enitity classes are attached.

The remove/delete in DAO class is as follows.

public String deleteName(String selectedValuesID) {

String returnValue = ERROR_MSG;
long id = (long)Integer.parseInt(selectedValuesID);

PromptsSelections prSel = getJpaTemplate().find(PromptsSelections.class,id);
getJpaTemplate().remove(prSel);

returnValue = SUCCESS_MSG;
return returnValue;

}

Thanks in Advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gyorke
Offline
Joined: 2005-06-21

This is a known issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=239540
To workaround the issue you can clear the PromptSelectionsDetails collection before calling remove on the parent.
--Gordon

dinesh_kb
Offline
Joined: 2008-07-29

I tried the following code in DAO class to remove the PromptSelectionsDetails List values before removing the parent entity. But it didn't solved my problem yet. Do you have any other way to overcome this?

List prSelDtlsList = (List)prSel.getPromptsSelectionsDetailsList();
for(PromptsSelectionsDetails pr:prSelDtlsList){
getJpaTemplate().remove(pr);
}

Thanks.