-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: criteria trouble
PostPosted: Thu Aug 17, 2006 9:05 am 
Beginner
Beginner

Joined: Tue Jun 06, 2006 3:37 am
Posts: 29
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.