SQL0532N exception when an entity bean deletes a record from a DB2 table and a foreign key reference to that record exists in another table
 Technote (troubleshooting)
 
Problem(Abstract)
The SQL0532N A parent row cannot be deleted because the relationship "constraint-name" restricts the deletion exception can be issued under several circumstances. The example in this technote is a common one.

Assume entity bean Bean A mapped to DB2® database table Table A and entity bean Bean B mapped to table Table B. Table A has a foreign key reference to the primary key of Table B.

A SQL0532N can be issued because of the transaction attribute setting when data from Table B is removed.
 
Cause
In this case a record is deleted from Table B by Bean B. This has the following two results:
 
Resolving the problem
This problem is caused by using transaction attribute Required for the setForeignKey() method for table A instead of using the recommended transaction attribute of RequiresNew.
When the delete method is called, an attempt is made to remove the record from the database immediately. The UPDATE does not occur until after the transaction ends. Therefore, the operations are out of order.

The solution is to set the transaction attribute to RequiresNew, which, creates a new transaction and forces the update to occur before the delete.
 
 
Cross Reference information
Segment Product Component Platform Version Edition
Application Servers Runtimes for Java Technology Java SDK
 
 


Document Information


Product categories: Software > Application Servers > Distributed Application & Web Servers > WebSphere Application Server > EJB Container
Operating system(s): Windows
Software version: 6.1
Software edition:
Reference #: 1170802
IBM Group: Software Group
Modified date: Aug 16, 2004