Master/Detail deletion problem

Hi, I've discovered strange behaviour of SunApp server 8.1.EE.

In one ejb interface method, which is mapped onto one DB transaction I try to remove several detail DB records and at the end of the method to remove a master (parent) record.

All but one details (children) and the master (parent) are realized asCMPs. One of the children is not mapped to an CMP but is deleted via custom DAO object (basically by calling delete ... SQL command).

The problem is :

AppServer changes the order of executed SQL commands, so it tries to delete master record prior to the detail record that should be deleted by DAO object!

Have anyone come to this?

I've discovered a thread, that discusses almost similar problem, but without DAO and is from 2003:

http://forum.sun.com/jive/thread.jspa?forumID=114&threadID=18942

Thanks Jan

[877 byte] By [Jan_Peremsky] at [2007-11-26 9:19:42]
# 1

Hi Jan,

The customer in the forum post was using EJB 1.1. Since beans in EJB

1.1 don't have relationships, CMP doesn't try to re-order SQL

statements to match database (foreign key) dependencies. But I

remember there was a very old bug that instances were not committed in

the user-defined order. But that was probably in AS 7.x times... This

should certainly not affect you.

To your problem:

In CMP 2.1, all instances are normally committed in the order of their

first modification. Commits are sometimes re-ordered to match database

constraints, preventing foreign key violations. This is required by

the EJB 2.1 spec.

As one child is not mapped as entity, CMP doesn't know about it. But

the non-mapped child should be removed immediately, whereas CMP

deletions are deferred until the end of the transaction, unless the

transaction executes a query. That's why I can't imagine why you're

seeing this error.

It would be great, if you could provide the code of the ejb interface

method and an cut-out of your server log for further

investigation. Can you try mapping the un-mapped child as a CMP bean?

m_fuchs at 2007-7-6 23:50:01 > top of Java-index,Application & Integration Servers,Application Servers...