TypedQuery<Person> query = entityManager.createQuery("from Person p where p.name = coalesce(:name , p.name) ", Person.class);
ParameterExpression<String> name = entityManager.getCriteriaBuilder().parameter(String.class, "name");
query.setParameter(name, null);
List<Person> resultList = query.getResultList();