I'm using Spring 2.5, Hibernate 3.2.6.ga and Oracle9Dialect. I'm trying to execute criteria query which fails with this message
Code:
org.hibernate.QueryException: could not resolve property: class of: com.nams.model.DeviceSummaryView
Here's the code: basically I have example class that may contain various properties some of which can have a wildcard
Code:
private List<DeviceSummaryView> searchByCriteria(DeviceSummaryView example)
throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {
assert(example != null);
DetachedCriteria criteria = DetachedCriteria
.forClass(DeviceSummaryView.class);
Map<String, Object> propMap = BeanUtils.describe(example);
Set<Entry<String, Object>> set = propMap.entrySet();
for (Entry<String, Object> entry : set) {
Object value = entry.getValue();
if (value != null && String.class.isInstance(value))
{
if (value.toString().indexOf('%') >= 0)
{
criteria.add(Expression.like(entry.getKey(), value));
} else
{
criteria.add(Property.forName(entry.getKey()).eq(value));
}
}
}
// DAO will simply call HibernateTemplate#findByCriteria
return this.deviceSummaryViewDao.findByCriteria(criteria);
}