Hi,
I'm new to hibernate and I'm facing a trouble while I'm trying to get values with a criteria
I've in my hbm the following line who define a relation between my object and an another table
Code:
<many-to-one name="usedTable"
class="com.mtsa.ebonus.core.db.UsedTableDb" fetch="select">
<column name="REF_TABLE" not-null="true" />
</many-to-one>
I'm trying to get the value defined in usedTable in my criteria like this way
Code:
Hashtable<String, String> otherFilter = new Hashtable<String, String>();
otherFilter.put("usedTable.name", "'PRODUCT'");
List<Element> elements = elementService.getFilteredElements(otherFilter);
the method getFilteredElements
Code:
public List<Element> getFilteredElements(Hashtable<String, String> filters) {
ec.log("Begin - getBrands(), filters: " + filters);
List<Element> result = null;
if (messageService == null) {
ec.handleError(ERR_SERVICE_IS_NULL);
} else {
List<Criterion> criterions = new ArrayList<Criterion>();
if (filters != null && filters.size() > 0) {
Enumeration<String> keys = filters.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
String value = filters.get(key);
criterions.add(Expression.eq(key, value));
}
}
List<ElementDb> dbEntities = this.elementDbDao.findByCriterions(criterions);
result = Element.convertFromDbEntities(dbEntities, messageService);
}
ec.log("End - getBrands(), result: " + result);
return result;
and the method findByCriterions
Code:
public List<ElementDb> findByCriterions(List<Criterion> criterions) {
ec.log("finding ElementDb instance(s) by Criterion List");
try {
Criteria criteria = getSession().createCriteria(ElementDb.class);
if (criterions!=null && !criterions.isEmpty()) {
for (Criterion criterion : criterions) {
criteria.add(criterion);
}
}
List<ElementDb> results = criteria.list();
ec.log("find by Criterion List successful, result size: " + results.size());
return results;
} catch (HibernateException he) {
ec.handleError("HibernateException", ErrorLevel.ERROR, he);
return null;
}
catch (DataAccessException dae) {
ec.handleError("DataAccessException", ErrorLevel.FATAL, dae);
return null;
}
}
the error message I get is the following :
Code:
Caused by: org.hibernate.QueryException: could not resolve property: usedTable.name of: com.mtsa.ebonus.core.db.ElementDb
thx for your help