HQL query problem
Posted
by yigit
on Stack Overflow
See other posts from Stack Overflow
or by yigit
Published on 2010-04-22T08:06:31Z
Indexed on
2010/04/22
8:13 UTC
Read the original article
Hit count: 247
Hi all,
I'm using this hql query for my filters. Query perfectly working except width (string) part.
Here is the query,
public IList<ColorGroup> GetDistinctColorGroups(int typeID, int finishID, string width)
{
string queryStr = "Select distinct c from ColorGroup c inner join c.Products p " +
"where p.ShowOnline = 1 ";
if (typeID > 0)
queryStr += " and p.ProductType.ID = " + typeID;
if (finishID > 0)
queryStr += " and p.FinishGroup.ID = " + finishID;
if (width != "")
queryStr += " and p.Size.Width = " + width;
IList<ColorGroup> colors = NHibernateSession.CreateQuery(queryStr).List<ColorGroup>();
return colors;
}
ProductType and Size have same mappings and relations.
This is the error;
NHibernate.QueryException: illegal syntax near collection: Size [Select distinct c from .Domain.ColorGroup c inner join c.Products p where p.ShowOnline = 1 and p.ProductType.ID = 1 and p.FinishGroup.ID = 5 and p.Size.Width = 4]
Any ideas ?
© Stack Overflow or respective owner