HHH-9710 - IllegalArgumentException passing null as parameter value with explicit TemporalType

(cherry picked from commit f940c72aa9)
This commit is contained in:
Steve Ebersole 2015-11-09 22:05:47 -06:00
parent 5169f77fb2
commit 06637289b8
1 changed files with 20 additions and 3 deletions

View File

@ -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();