Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 30292 invoked from network); 18 Apr 2008 15:33:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Apr 2008 15:33:32 -0000 Received: (qmail 77226 invoked by uid 500); 18 Apr 2008 15:33:33 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 77211 invoked by uid 500); 18 Apr 2008 15:33:33 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 77202 invoked by uid 99); 18 Apr 2008 15:33:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 08:33:33 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Apr 2008 15:32:58 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7B6A8234C0E1 for ; Fri, 18 Apr 2008 08:30:21 -0700 (PDT) Message-ID: <2017945643.1208532621504.JavaMail.jira@brutus> Date: Fri, 18 Apr 2008 08:30:21 -0700 (PDT) From: "Sandeep Shrivastava (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Created: (OPENJPA-576) Recursively embedded entities generate an extra and reduntant SQL call to the database. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Recursively embedded entities generate an extra and reduntant SQL call to the database. --------------------------------------------------------------------------------------- Key: OPENJPA-576 URL: https://issues.apache.org/jira/browse/OPENJPA-576 Project: OpenJPA Issue Type: Bug Components: jdbc Environment: OpenJPA 1.1.0-SNAPSHOT version id: openjpa-1.1.0-SNAPSHOT-r422266:647033 Apache svn revision: 422266:647033 os.name: Windows XP os.version: 5.1 os.arch: x86 java.version: 1.6.0_05 java.vendor: BEA Systems, Inc. Reporter: Sandeep Shrivastava Fix For: 1.1.0 Consider the following persistent class model. The accessor methods are removed for the sake of brevity. public class EmbeddedOwnerPC { private int id1; private int id2; private String stringField; private EmbeddedPC embedded; private ComplexEmbeddedPC complexEmbedded; } public class EmbeddedPC { private int intField; private String stringField; } public class ComplexEmbeddedPC extends RecursivelyEmbeddedPC { private String stringField; private EmbeddedOwnerPC ownerField; private Set stringSet = new HashSet(); } public class RecursivelyEmbeddedPC { private EmbeddedPC embedded; } When trying to retrieve the EmbeddedOwner entity with a given fetch plan that includes the complexEmbedded and the embedded fields in the RecursivelyEmbeddedPC class it generate the following 2 SQL statements to load the entity. SELECT t0.TYP, t0.VERSN, t0.EMBEDDED_NULL, t0.ID1, t0.ID2, t0.INTFIELD1, t0.STRINGFIELD3, t0.STRINGFIELD FROM EMBEDDEDOWNERPC t0 WHERE t0.ID1 = ? AND t0.ID2 = ? FOR UPDATE SELECT t0.ID1, t0.ID2 FROM EMBEDDEDOWNERPC t0 WHERE t0.ID1 = ? AND t0.ID2 = ? FOR UPDATE The second call is reduntant and not needed. The fix is to the EmbedFieldStrategy class load method to ensure that all fields that are required to be loaded as per the fetch plan and included from the result set and ONLY when this is not true then generate the extra call otherwise return a hollow embedded entity. In the above test case the extra call was generated to get the stringSet field which was not specified in the fetch plan but the call is made out nevertheless which just selects the primary keys with the same where clause. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.