From fb1b4837215bb08db509c508e83e29ac898922d8 Mon Sep 17 00:00:00 2001 From: James Gilbertson Date: Fri, 7 Oct 2011 23:10:20 -0600 Subject: [PATCH] HHH-4881: Added test cases for parameterized discriminator type --- .../org/hibernate/test/discriminator/SimpleInheritanceTest.java | 2 ++ .../org/hibernate/test/joinedsubclass/JoinedSubclassTest.java | 2 ++ .../org/hibernate/test/unionsubclass/UnionSubclassTest.java | 2 ++ .../org/hibernate/test/unionsubclass2/UnionSubclassTest.java | 2 ++ 4 files changed, 8 insertions(+) diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/discriminator/SimpleInheritanceTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/discriminator/SimpleInheritanceTest.java index fd9960657b..f39f1362e1 100644 --- a/hibernate-core/src/matrix/java/org/hibernate/test/discriminator/SimpleInheritanceTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/discriminator/SimpleInheritanceTest.java @@ -88,6 +88,8 @@ public class SimpleInheritanceTest extends BaseCoreFunctionalTestCase { assertEquals( s.createQuery("from org.hibernate.test.discriminator.Person").list().size(), 3 ); assertEquals( s.createQuery("from org.hibernate.test.discriminator.Person p where p.class = org.hibernate.test.discriminator.Person").list().size(), 1 ); assertEquals( s.createQuery("from org.hibernate.test.discriminator.Person p where p.class = org.hibernate.test.discriminator.Customer").list().size(), 1 ); + assertEquals( s.createQuery("from org.hibernate.test.discriminator.Person p where type(p) = :who").setParameter("who", Person.class).list().size(), 1 ); + assertEquals( s.createQuery("from org.hibernate.test.discriminator.Person p where type(p) in :who").setParameterList("who", new Class[] {Customer.class, Person.class}).list().size(), 2 ); s.clear(); List customers = s.createQuery("from org.hibernate.test.discriminator.Customer").list(); diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java index 68b1c84ac1..d6780eb501 100755 --- a/hibernate-core/src/matrix/java/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/joinedsubclass/JoinedSubclassTest.java @@ -88,6 +88,8 @@ public class JoinedSubclassTest extends BaseCoreFunctionalTestCase { assertEquals( s.createQuery("from Person").list().size(), 3 ); assertEquals( s.createQuery("from Person p where p.class = Customer").list().size(), 1 ); assertEquals( s.createQuery("from Person p where p.class = Person").list().size(), 1 ); + assertEquals( s.createQuery("from Person p where type(p) in :who").setParameter("who", Customer.class).list().size(), 1 ); + assertEquals( s.createQuery("from Person p where type(p) in :who").setParameterList("who", new Class[] {Customer.class, Person.class}).list().size(), 2 ); s.clear(); List customers = s.createQuery("from Customer c left join fetch c.salesperson").list(); diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java index 1b2b769082..6f2b5951e9 100755 --- a/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java @@ -318,6 +318,8 @@ public class UnionSubclassTest extends BaseCoreFunctionalTestCase { assertEquals( s.createQuery("from Being").list().size(), 2 ); assertEquals( s.createQuery("from Being b where b.class = Alien").list().size(), 1 ); + assertEquals( s.createQuery("from Being b where type(b) = :what").setParameter("what", Alien.class).list().size(), 1 ); + assertEquals( s.createQuery("from Being b where type(b) in :what").setParameterList("what", new Class[] { Alien.class, Human.class }).list().size(), 2 ); assertEquals( s.createQuery("from Alien").list().size(), 1 ); s.clear(); diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java index 716a590456..903a805735 100755 --- a/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java @@ -86,6 +86,8 @@ public class UnionSubclassTest extends BaseCoreFunctionalTestCase { assertEquals( s.createQuery("from Person").list().size(), 3 ); assertEquals( s.createQuery("from Person p where p.class = Customer").list().size(), 1 ); assertEquals( s.createQuery("from Person p where p.class = Person").list().size(), 1 ); + assertEquals( s.createQuery("from Person p where type(p) in :who").setParameter("who", Customer.class).list().size(), 1 ); + assertEquals( s.createQuery("from Person p where type(p) in :who").setParameterList("who", new Class[] {Customer.class, Person.class}).list().size(), 2 ); s.clear(); List customers = s.createQuery("from Customer c left join fetch c.salesperson").list();