Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 42204 invoked from network); 1 May 2010 03:21:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 1 May 2010 03:21:29 -0000 Received: (qmail 56346 invoked by uid 500); 1 May 2010 03:21:28 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 56147 invoked by uid 500); 1 May 2010 03:21:28 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 56139 invoked by uid 99); 1 May 2010 03:21:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 May 2010 03:21:27 +0000 X-ASF-Spam-Status: No, hits=4.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_HELO_PASS,SPF_NEUTRAL,T_TO_NO_BRKTS_FREEMAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 May 2010 03:21:20 +0000 Received: from jim.nabble.com ([192.168.236.80]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1O83GE-0001c9-9C for users@openjpa.apache.org; Fri, 30 Apr 2010 20:20:58 -0700 Date: Fri, 30 Apr 2010 20:20:58 -0700 (PDT) From: JayaPrakash To: users@openjpa.apache.org Message-ID: <1272684058277-4988887.post@n2.nabble.com> Subject: Order of Insert/Update statement vs @ElementDependent MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_81171_2436541.1272684058277" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_81171_2436541.1272684058277 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi All, I am into a very tricky situation here on our application. To order the Inserts/Updates SQLs from parent to child, I have used the property in the persistence.xml. This works perfect. The actual problem is that I am also using @ElementDependent annotation for the orphan deletion and this causes the issue. Example: In a typical scenario of OneToMany bidirectional relationship between A to B and B to C, I am annotating @ElementDependent in the relationship mapping from A to B and B to C. In some scenarios, when we want to delete all of the B records, we nullify the List property inside B and call entityManager.merge(A). Everything was working fine until we added the configuration to the persistence.xml as mentioned above. The above usecase starting giving errors of late and to analyze the problem we enabled the SQL trace and monitoring the generated SQLs gave us enough hint about the problem. As part of update process for A, it is generating all the Update statements for other objects associated with it and Delete statements for all the B objects, which is correct. But the strange thing is that in the of the list of Update statements generated, We could also see that a bunch of Update statements are generated for C as well (In theory they should never be because their parents are marked for deletion so these should also be deleted) and also it is trying to update the C record with null foreing key value which is actually causing the error. Also another important point to note here is that the OpenJPA still generates Delete statements for C objects. But in the order of SQLs the Updates are before the Deletes. What I dont understand is that why is OpenJPA trying to update the children (C) of an object (B) before deletion when B is marked for deletion. Again, this started happening only after adding the property in persistence file for ordering of inserts. I kindly request you to help me clearing this problem. I cannot afford to ignore either order of SQLs or @ElementDependent as both are two eyes of my application. Thanks in advance. -- View this message in context: http://openjpa.208410.n2.nabble.com/Order-of-Insert-Update-statement-vs-ElementDependent-tp4988887p4988887.html Sent from the OpenJPA Users mailing list archive at Nabble.com. ------=_Part_81171_2436541.1272684058277--