Hey!
I am trying to write a query by example, but i faced the following problem.
If am passing an example object, with a primary key field initialized, then i get back the list of all records in my table.
of course one of the possibilities is to write own implementation of PropertySelector. but i would like to write fetch methods that can be used with any persistent object.
Here is my example
Code:
public Object getObjectByExample(Object object) throws HibernateException {
List objectList = this.getObjectListByExample(object);
object = (objectList.isEmpty() ? null : objectList.get(0));
return object;
}
public List getObjectListByExample(Object object) throws HibernateException {
Session session = DaoSession.open();
Example example = Example.create(object);
List objectList = session.createCriteria(object.getClass()).add(example)
.list();
return objectList;
}
Thanks!