mirror of https://github.com/apache/openjpa.git
OPENJPA-508 Merge from ../branches/1.0.x. svn merge -c 617760 ../branches/1.0.x
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@617763 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8ba8ffffc4
commit
18c90bbd0b
|
@ -302,8 +302,8 @@ public class SelectConstructor
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -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 @@ public class TestDiscriminatorTypes extends SingleEMFTestCase {
|
|||
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() {
|
||||
|
@ -144,4 +146,33 @@ public class TestDiscriminatorTypes extends SingleEMFTestCase {
|
|||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue