Return-Path: X-Original-To: apmail-openjpa-dev-archive@www.apache.org Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 37881D237 for ; Wed, 21 Nov 2012 13:04:00 +0000 (UTC) Received: (qmail 2690 invoked by uid 500); 21 Nov 2012 13:03:59 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 2609 invoked by uid 500); 21 Nov 2012 13:03:59 -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 2563 invoked by uid 99); 21 Nov 2012 13:03:58 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Nov 2012 13:03:58 +0000 Date: Wed, 21 Nov 2012 13:03:58 +0000 (UTC) From: "Vermeulen (JIRA)" To: dev@openjpa.apache.org Message-ID: <1279798173.12084.1353503038825.JavaMail.jiratomcat@arcas> In-Reply-To: <919366523.12067.1353502678757.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (OPENJPA-2299) N+1 select when eager fetching two collection fields of the same entity type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-2299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Vermeulen updated OPENJPA-2299: ------------------------------- Attachment: OPENJPA-2299-tests.zip Added an OpenJPA test case which shows the problem. > N+1 select when eager fetching two collection fields of the same entity type > ---------------------------------------------------------------------------- > > Key: OPENJPA-2299 > URL: https://issues.apache.org/jira/browse/OPENJPA-2299 > Project: OpenJPA > Issue Type: Bug > Components: jdbc, jpa, performance > Affects Versions: 2.3.0, 2.2.1 > Reporter: Vermeulen > Attachments: OPENJPA-2299-tests.zip > > > I have a ProductOrder entity that has two @OneToMany lists of ProductOrderLines. When selecting from ProductOrder, eager fetching does not seem to recurse into the second list so that each field of each ProductOrderLine in the second list is fetched using a separate "load field" operation. > The problem does not occur when there is only one List. > @Entity > public class ProductOrder { > @JoinColumn(name = "PLANNED_ORDER_ID") > @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) > private List plannedOrderLines = new ArrayList(); > @JoinColumn(name = "ACTUAL_ORDER_ID") > @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) > private List actualOrderLines = new ArrayList(); > Expected nr of queries: 1 (for Order) + 1 (for Order.plannedOrderLines) + 1 (for Order.actualOrderLines). > Actual nr of queries: same as expected + 1 query for each field of each ProductOrderLine in Order.actualOrderLines. > Same problem exists when using @JoinTable instead of @JoinColumn (JPA 2.0 only). -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira