openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r617763 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
Date Sat, 02 Feb 2008 06:42:22 GMT
Author: pcl
Date: Fri Feb  1 22:42:20 2008
New Revision: 617763

URL: http://svn.apache.org/viewvc?rev=617763&view=rev
Log:
OPENJPA-508 Merge from ../branches/1.0.x. svn merge -c 617760 ../branches/1.0.x

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java?rev=617763&r1=617762&r2=617763&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/exps/SelectConstructor.java
Fri Feb  1 22:42:20 2008
@@ -302,8 +302,8 @@
         }
 
         // add conditions limiting the projections to the proper classes; if
-        // this isn't a projection then they will already be added
-        if (exps.projections.length > 0) {
+        // this isn't a projection or a subq then they will already be added
+        if (exps.projections.length > 0 || sel.getParent() != null) {
             ctx.store.loadSubclasses(mapping);
             mapping.getDiscriminator().addClassConditions((inner != null) 
                 ? inner : sel, subclasses, joins);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java?rev=617763&r1=617762&r2=617763&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/discriminator/TestDiscriminatorTypes.java
Fri Feb  1 22:42:20 2008
@@ -18,7 +18,9 @@
  */
 package org.apache.openjpa.persistence.discriminator;
 
+import java.util.List;
 import javax.persistence.EntityManager;
+import javax.persistence.Query;
 
 import org.apache.openjpa.jdbc.meta.ClassMapping;
 import org.apache.openjpa.jdbc.meta.Discriminator;
@@ -32,7 +34,7 @@
                 CharRootEntity.class, IntegerAbstractEntity.class,
                 IntegerLeafEntity.class, IntegerRootEntity.class,
                 StringAbstractEntity.class, StringLeafEntity.class,
-                StringRootEntity.class);
+                StringRootEntity.class, CLEAR_TABLES, "openjpa.Log", "SQL=TRACE");
     }
 
     public void testCharDiscriminators() {
@@ -142,6 +144,35 @@
         
         assertNotNull(leaf2);
         assertNotNull(root2);
+        em.close();
+    }
+
+    public void testExistsQuery() {
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+
+        StringRootEntity e = new StringRootEntity();
+        e.setName("foo");
+        em.persist(e);
+
+        e = new StringRootEntity();
+        e.setName("foo");
+        em.persist(e);
+
+        e = new StringRootEntity();
+        e.setName("bar");
+        em.persist(e);
+
+        em.getTransaction().commit();
+        em.close();
+
+        em = emf.createEntityManager();
+        Query q = em.createQuery("select o from StringAbstractEntity o " +
+            "where exists (select o2 from StringLeafEntity o2)");
+        List<StringAbstractEntity> list = q.getResultList();
+        assertEquals(0, list.size());
+        for (StringAbstractEntity entity : list)
+            assertTrue(entity instanceof StringLeafEntity);
         em.close();
     }
 }



Mime
View raw message