Hi,
I was developing a generic method to get objects by example. The
problem is that I have to inform the Class object, so I can search for
all objects in case of a null parameter.
Is it possible to get the object class from the generic type T?
public <T> List<T> getObject(final T o, final Class<T> clazz) {
if (o == null) {
return getObjects(clazz);
} else {
HibernateCallback callback = new HibernateCallback(){
public Object doInHibernate(org.hibernate.Session
session) throws HibernateException, SQLException
{
Example ex =
Example.create(o).ignoreCase().enableLike(MatchMode.ANYWHERE);
return session.createCriteria(clazz).add(ex).list();
}
};
return (List<T>) getHibernateTemplate().execute(callback);
}
}
Luiz
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]