From 06637289b81af46f16cc43fbbdc1e551f7d70ccb Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 9 Nov 2015 22:05:47 -0600 Subject: [PATCH] HHH-9710 - IllegalArgumentException passing null as parameter value with explicit TemporalType (cherry picked from commit f940c72aa901fe0b0473d9d9effc97255241082d) --- .../jpa/test/query/DateTimeParameterTest.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/query/DateTimeParameterTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/query/DateTimeParameterTest.java index 4e0da65b22..3e8e980b63 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/query/DateTimeParameterTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/query/DateTimeParameterTest.java @@ -6,6 +6,9 @@ */ package org.hibernate.jpa.test.query; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; import javax.persistence.Entity; import javax.persistence.EntityManager; import javax.persistence.Id; @@ -13,9 +16,6 @@ import javax.persistence.Query; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.List; import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; @@ -56,6 +56,23 @@ public class DateTimeParameterTest extends BaseEntityManagerFunctionalTestCase { deleteTestData(); } + @Test + public void testBindingNulls() { + EntityManager em = getOrCreateEntityManager(); + em.getTransaction().begin(); + + try { + Query query = em.createQuery( "from Thing t where t.someDate = :aDate or t.someTime = :aTime or t.someTimestamp = :aTimestamp" ); + query.setParameter( "aDate", (Date) null, TemporalType.DATE ); + query.setParameter( "aTime", (Date) null, TemporalType.DATE ); + query.setParameter( "aTimestamp", (Date) null, TemporalType.DATE ); + } + finally { + em.getTransaction().rollback(); + em.close(); + } + } + private void createTestData() { EntityManager em = getOrCreateEntityManager(); em.getTransaction().begin();