From 5c5998aea929a3a9ee8230cc572320b27fc8163e Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Wed, 16 Jan 2013 18:28:09 -0500 Subject: [PATCH] HHH-2951 test case --- .../test/criteria/CriteriaQueryTest.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java b/hibernate-core/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java index 5d80830c8a..7024699990 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/criteria/CriteriaQueryTest.java @@ -2046,6 +2046,32 @@ public class CriteriaQueryTest extends BaseCoreFunctionalTestCase { t.rollback(); s.close(); } + + @Test + @TestForIssue( jiraKey = "HHH-2951" ) + public void testNullCriteria() { + Course course = new Course(); + course.setCourseCode( "1234" ); + course.setDescription( null ); + + Session s = openSession(); + Transaction t = s.beginTransaction(); + + s.persist( course ); + s.flush(); + s.clear(); + + // Ensure Restrictions creates "where foo is null", instead of + // "where foo = null" + List courses = s.createCriteria( Course.class ).add( + Restrictions.eq( "description", null) ).list(); + + assertEquals( courses.size(), 1 ); + assertEquals( courses.get( 0 ).getCourseCode(), course.getCourseCode() ); + + t.rollback(); + s.close(); + } }