From dev-return-13957-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Sat Oct 10 19:04:56 2009 Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 30014 invoked from network); 10 Oct 2009 19:04:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Oct 2009 19:04:56 -0000 Received: (qmail 22669 invoked by uid 500); 10 Oct 2009 19:04:55 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 22607 invoked by uid 500); 10 Oct 2009 19:04:55 -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 22597 invoked by uid 99); 10 Oct 2009 19:04:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Oct 2009 19:04:55 +0000 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; Sat, 10 Oct 2009 19:04:52 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 53E9E234C045 for ; Sat, 10 Oct 2009 12:04:31 -0700 (PDT) Message-ID: <1424237873.1255201471330.JavaMail.jira@brutus> Date: Sat, 10 Oct 2009 12:04:31 -0700 (PDT) From: "Milosz Tylenda (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-894) LEFT JOIN FETCH queries with fresh fetches from the db do not follow JPA Spec 4.4.5.3 In-Reply-To: <580150673.1233698399894.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-894?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Milosz Tylenda updated OPENJPA-894: ----------------------------------- Patch Info: [Patch Available] > LEFT JOIN FETCH queries with fresh fetches from the db do not follow JPA Spec 4.4.5.3 > ------------------------------------------------------------------------------------- > > Key: OPENJPA-894 > URL: https://issues.apache.org/jira/browse/OPENJPA-894 > Project: OpenJPA > Issue Type: Bug > Components: query > Affects Versions: 1.2.0 > Environment: Any, tested with Windows > Reporter: Jody Grassel > Attachments: FetchJoinTest.zip, OPENJPA-894.patch > > > Discovered what seems to be a break with JPA Specification 1.0, section 4.4.5.3 (Fetch Joins). The query in question uses the LEFT JOIN FETCH sematic, so there is the expectation that the result list will contain a copy of the entity reference for every match on the right side of the join (the spec uses the example with the query "SELECT d FROM department d LEFT JOIN FETCH d.employees WHERE d.deptno = 1" where 5 employees are members of department(pk=1) the resultlist should have 5 copies of Department(pk=1). ) > Now, if I create all of the entities, persist them to the database, but do not clear the persistence context (leaving all the new entities managed by the persistence context still), the query performs as expected. I get multiple copies of the entity I issued the query for, one for each item successfully matching the LEFT JOIN FETCH. In the example I will update shortly, I get: > [junit] -------------------------------------------------- > [junit] Executing testQuery001 > [junit] Executing named query getAGroup with intData=42 ... > [junit] ResultList size: 8 > [junit] 1 EntityA(id=1): 42, Entity A - PK 1 > [junit] 1 EntityA(id=1): 42, Entity A - PK 1 > [junit] 1 EntityA(id=1): 42, Entity A - PK 1 > [junit] 1 EntityA(id=1): 42, Entity A - PK 1 > [junit] 1 EntityA(id=2): 42, Entity A - PK 2 > [junit] 1 EntityA(id=2): 42, Entity A - PK 2 > [junit] 1 EntityA(id=2): 42, Entity A - PK 2 > [junit] 1 EntityA(id=2): 42, Entity A - PK 2 > However, if I clear the persistence context, forcing OpenJPA to make a fetch from the database, I only get unique instances of the entity I issued the query for, not multiple copies for each match on the right side of the join. > [junit] -------------------------------------------------- > [junit] Executing testQuery002 > [junit] Clearing persistence context... > [junit] Executing named query getAGroup with intData=42 ... > [junit] ResultList size: 2 > [junit] 1 EntityA(id=1): 42, Entity A - PK 1 > [junit] 1 EntityA(id=2): 42, Entity A - PK 2 > Both tests use the exact same code for everything, except testQuery002 does a em.clear() before running the query. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.