As already mentioned, the address column is empty, and then try using the IS EMPTY expression instead of IS NULL .
em.createQuery( "SELECT o FROM Person o where (o.address.id IS NULL OR o.address.id = 0").setMaxResults(50).getResultList();
Check restriction according to id data type.
Also, there is no need to mention setFirstResult (0) , since it is not going to skip any results without it, by default all relevant results will be obtained.
Nayan wadekar
source share