Let say I have a class Employee with name, surname, city, etc. Is there a way to perform a hibernate query, either using HQL or Criteria query and to get a value how the object created as pattern (i.e. in Criteria Query By Example) match to the persisted objects? Somehow giving an matching coefficient, because I would like to have an order results by matching, not how they are persisted in a rdB.
Thanks, Ivan
EDIT:
More illustrative example.
object1.setColor("Red");
object1.setShape("Round");
session.save(object1);
object2.setColor("Red");
object2.setShape("Rect");
session.save(object2);
object3.setShape("Round");
object3.setColor("Blue");
session.save(object3);
Now perform Criteria search
Criteria crit = session.createCriteria(XYZ.class);
Disjunction or = Restrictions.disjunction();
or.add(Restrictions.ilike("color", "blue"));
or.add(Restrictions.ilike("shape", "round"));
crit.add(or);
In this way I would get in the list crit.list();
1) object1 2) object3
The order is dependent how it is persisted (saved). But as you seen the object3 is 100% matched (both criterias are satisfied), where the object1 is 50% matched. Nevertheless I cannot get that "matching information" using the code above. So my question is whether hibernate have such functionality that can provide me how much the persisted object match the one defined in criteria?
I hope now the question is more clear.