rajasaur wrote:
I created a many-to-one between Product and Category and creating a Criteria query like
Criteria crit = session.createCriteria(test.Category.class).createCriteria("products");
crit.add(Restrictions.isNull("category"));
and it did create a query like
Hibernate: select this_.CATEGORY_ID as CATEGORY1_1_, this_.CATEGORY_NAME as CATEGORY2_0_1_, product1_.PRODUCT_ID as PRODUCT1_0_, product1_.PRODUCT_NAME as PRODUCT2_1_0_, product1_.CATEGORY_ID as CATEGORY3_1_0_
from CATEGORY this_ inner join PRODUCT product1_
on this_.CATEGORY_ID=product1_.CATEGORY_ID
where product1_.CATEGORY_ID is null.
This seems to me really senseless. Your query will never return any rows, because if the where clause is true, the join condition cannot be true - due to the inner join no result is ever possible.