Query query = em.createQuery(
"select count(u) from User u where (u.id=:a) and (u.photo=:b)")
.setParameter("a",userId).setParameter("b",null);
In my case, I want check whether user photo uploaded or not (photo value is null or not). I tried above query.