-->
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: How to do the Join with Criteria
PostPosted: Tue Oct 06, 2009 5:27 am 
Newbie

Joined: Tue Oct 06, 2009 5:06 am
Posts: 1
Hallo Guys,
I'm quite new to Hibernate and having a problem with joining two tables:

Table1: ins => InformationSystemContainer
Rows: ID_BB, NAME

Table2: isr => InformationSystemRelease
Rows: ID_BB, VERSION, ID_INS

"ID_INS" contains the primary key of the corresonding Container.

The result shall be a list of all InformationSystemReleases, whose VERSION is like a String "searchTerm" OR its InformationSystemContainer's NAME is like that String.

This is my try until now an works fine if the "searchTerm" is empty. But if not, there is an "org.hibernate.QueryException: could not resolve property: ins of: de.iteratec.iteraplan.model.InformationSystemRelease"
Code:
public List<E> getMatchesWithJoin(final String searchedProperty,
                                               final String searchTerm, final int firstResult,
                                               final int maxResult {

public Object doInHibernate(Session session) throws HibernateException, SQLException {
        Criteria c = session.createCriteria(getPersistentClass());

        if (StringUtils.isNotEmpty(searchTerm)) {
          String sqlSearchTerm = GeneralHelper.processGuiFilterForSql(searchTerm);
          c.add(Restrictions.or(new LikeExpression("ins.NAME", sqlSearchTerm, true), new LikeExpression("VERSION", sqlSearchTerm,
              true)));
        }
        c.setFirstResult(firstResult);
        c.setMaxResults(maxResult);
        return c.list();
      }
    };
return (List<E>) getHibernateTemplate().execute(callback);
}


Well... does anyone know a solution or can give a little help how to add the JOIN of those two tables, I'd be grateful.

Regards
Moe


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.