diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java index 5a4ff1cbb5..3e500c6786 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java @@ -262,6 +262,55 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase { s.close(); } + @Test + @FailureExpected( jiraKey = "HHH-9154" ) + public void testClassAsParameter() { + // just checking syntax here... + Session s = openSession(); + s.beginTransaction(); + + /////////////////////////////////////////////////////////////// + // where clause + // control + s.createQuery( "from Animal a where a.class = :class" ).setParameter( "class", Dog.class ).list(); + + /////////////////////////////////////////////////////////////// + // select clause (at some point we should unify these) + // control + Query query = s.createQuery( "select a.class from Animal a where a.class = :class" ).setParameter( "class", Dog.class ); + query.list(); // checks syntax + assertEquals( 1, query.getReturnTypes().length ); + assertEquals( Integer.class, query.getReturnTypes()[0].getReturnedClass() ); // always integer for joined + // test + query = s.createQuery( "select type(a) from Animal a where type(a) = Dog" ); + query.list(); // checks syntax + assertEquals( 1, query.getReturnTypes().length ); + assertEquals( DiscriminatorType.class, query.getReturnTypes()[0].getClass() ); + assertEquals( Class.class, query.getReturnTypes()[0].getReturnedClass() ); + + s.getTransaction().commit(); + s.close(); + } + + @Test + @FailureExpected( jiraKey = "HHH-9154" ) + public void testObjectAsParameter() { + Session s = openSession(); + s.beginTransaction(); + + Type[] types = s.createQuery( "select h.name from Human h" ).getReturnTypes(); + assertEquals( 1, types.length ); + assertTrue( types[0] instanceof ComponentType ); + + s.createQuery( "from Human h where h.name = :Object" ).setParameter( "object", new Name() ).list(); + s.createQuery( "from Human where name = :object" ).setParameter( "object", new Name() ).list(); + s.createQuery( "from Human h where :object = h.name" ).setParameter( "object", new Name() ).list(); + s.createQuery( "from Human h where :object <> h.name" ).setParameter( "object", new Name() ).list(); + + s.getTransaction().commit(); + s.close(); + } + @Test public void testComponentJoins() { Session s = openSession();