|
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 |
|
|
|
|
|
|