From dev-return-21424-apmail-openjpa-dev-archive=openjpa.apache.org@openjpa.apache.org Fri Jan 4 21:30:13 2013 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 80E6FE57B for ; Fri, 4 Jan 2013 21:30:13 +0000 (UTC) Received: (qmail 73367 invoked by uid 500); 4 Jan 2013 21:30:13 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 73315 invoked by uid 500); 4 Jan 2013 21:30:13 -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 73290 invoked by uid 99); 4 Jan 2013 21:30:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jan 2013 21:30:13 +0000 Date: Fri, 4 Jan 2013 21:30:12 +0000 (UTC) From: "Lev (JIRA)" To: dev@openjpa.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (OPENJPA-2317) Criteria API doesn' generate LEFT OUTER JOIN in subquery as expected MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Lev created OPENJPA-2317: ---------------------------- Summary: Criteria API doesn' generate LEFT OUTER JOIN in subquery as expected Key: OPENJPA-2317 URL: https://issues.apache.org/jira/browse/OPENJPA-2317 Project: OpenJPA Issue Type: Bug Components: criteria Affects Versions: 2.1.1 Environment: Windows/Oracle Reporter: Lev I have 3 entity classes classes @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class DiscoveryObjectImpl implements DiscoveryObject { @Id private String id; public String getId() { return id; } public void setId(String id) { this.id = id; } } @Entity public class VirtualTableImpl extends DiscoveryObjectImpl { @OneToMany(mappedBy="table") private List column = new ArrayList(); } @Entity public class ColumnImpl extends DiscoveryObjectImpl { @ManyToOne(cascade = CascadeType.PERSIST, optional=true) VirtualTableImpl table; } test code public void test() { EntityManager em = OpenJPAPersistence.createEntityManagerFactory("Test", "test/persistence.xml").createEntityManager(); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery cri = cb.createQuery(VirtualTableImpl.class); Root tbl = cri.from(VirtualTableImpl.class); Subquery sq = cri.subquery(Integer.class); Root tbl1 = sq.from(VirtualTableImpl.class); Path cols = tbl1.join("column", JoinType.LEFT); sq.where(cb.isNull(cols), cb.equal(tbl1, tbl)); sq.select(cb.literal(new Integer(1))); cri.where(cb.exists(sq)); em.createQuery(cri).getResultList(); } persistence.xml org.apache.openjpa.persistence.PersistenceProviderImpl com.ibm.infosphere.test.model.interfaces.impl.DiscoveryObjectImpl com.ibm.infosphere.test.model.interfaces.impl.VirtualTableImpl com.ibm.infosphere.test.model.interfaces.impl.ColumnImpl true The SQL trace is as the following SELECT t2.id FROM VirtualTableImpl t2 WHERE (EXISTS (SELECT ? FROM VirtualTableImpl t0 INNER JOIN ColumnImpl t1 ON t0.id = t1.TABLE_ID WHERE (t1.id IS NULL AND t0.id = t2.id))) Please note that sub query contains INNER JOIN instead of LEFT OUTER JOIN -- 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