and this is not only limited to null checks in combination with parameters
String hql = "select r from MyUser r where 1=1 and r.firstname = :firstname";
Query query = entityManager.createQuery(hql);
query.setParameter("firstname", null);
Object result = query.getSingleResult();
results in
select
m1_0.MY_USER_ID,
m1_0.FIRSTNAME,
m1_0.LASTNAME
from
MY_USER m1_0
where
1=1
and 1 is not null
and 1 is not null
and m1_0.FIRSTNAME=?
and m1_0.FIRSTNAME is not null