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