@@ -0,0 +1,2346 @@
+package com.vladmihalcea.book.hpjp.hibernate.query;%0A%0Aimport com.vladmihalcea.book.hpjp.util.AbstractPostgreSQLIntegrationTest;%0Aimport org.hibernate.cfg.AvailableSettings;%0Aimport org.hibernate.query.NativeQuery;%0Aimport org.hibernate.type.StringType;%0Aimport org.junit.Ignore;%0Aimport org.junit.Test;%0A%0Aimport javax.persistence.*;%0Aimport java.sql.Timestamp;%0Aimport java.time.LocalDateTime;%0Aimport java.time.ZoneOffset;%0Aimport java.util.List;%0Aimport java.util.Properties;%0A%0A/**%0A * @author Vlad Mihalcea%0A */%0Apublic class PostgreSQLNativeQueryNullParameterTest extends AbstractPostgreSQLIntegrationTest %7B%0A%0A    @Override%0A    protected Class%3C?%3E%5B%5D entities() %7B%0A        return new Class%3C?%3E%5B%5D %7B%0A            Event.class%0A        %7D;%0A    %7D%0A%0A    @Test%0A    public void test() %7B%0A        doInJPA(entityManager -%3E %7B%0A            Event firstPartRelease = new Event();%0A            firstPartRelease.setName(%22High-Performance Java Persistence Part I%22);%0A            firstPartRelease.setCreatedOn(%0A                Timestamp.from(LocalDateTime.of(2015, 11, 2, 9, 0, 0).toInstant(ZoneOffset.UTC))%0A            );%0A            entityManager.persist(firstPartRelease);%0A        %7D);%0A%0A        //Explicit cast needed as a workaround for HHH-13155%0A        doInJPA(entityManager -%3E %7B%0A            List%3CEvent%3E events = entityManager%0A            .createNativeQuery(%0A                %22SELECT * %22 +%0A                %22FROM Event %22 +%0A                %22WHERE (:name is null or name = :name)%22, Event.class)%0A            .unwrap(NativeQuery.class)%0A            .setParameter(%22name%22, null, StringType.INSTANCE)%0A            .getResultList();%0A        %7D);%0A    %7D%0A%0A    @Entity(name = %22Event%22)%0A    @Table(name = %22event%22)%0A    public static class Event %7B%0A%0A        @Id%0A        @GeneratedValue%0A        private long id;%0A%0A        private String name;%0A%0A        @Column(name = %22created_on%22)%0A        private Timestamp createdOn;%0A%0A        public long getId() %7B%0A            return id;%0A        %7D%0A%0A        public void setId(long id) %7B%0A            this.id = id;%0A        %7D%0A%0A        public String getName() %7B%0A            return name;%0A        %7D%0A%0A        public void setName(String name) %7B%0A            this.name = name;%0A        %7D%0A%0A        public Timestamp getCreatedOn() %7B%0A            return createdOn;%0A        %7D%0A%0A        public void setCreatedOn(Timestamp createdOn) %7B%0A            this.createdOn = createdOn;%0A        %7D%0A    %7D%0A%7D%0A

Add workaround for HHH-13155