I have trying to understand how does an Example query in Hibernate works.
deptId is the primary key of the departments table.
I tried this code initially:
Dept department = new Dept();
department.setDeptId(3);
//department.setDeptName("ABCD");
Criteria criteria = session.createCriteria(Dept.class).add(Example.create(department));
Executing this code, the results are not getting filtered w.r.t the rows having deptId = 3 i.e, the SQL Query is equivalent to selecting all records from Dept table where 1 = 1.
But if i consider this code:
Dept department = new Dept();
//department.setDeptId(3);
department.setDeptName("ABCD");
Criteria criteria = session.createCriteria(Dept.class).add(Example.create(department));
The results are getting filtered w.r.t the deptName i.e. ABCD
Please inform why is the Example query behaving like this.