Hi,
I need help to translate a HQL query to a QBC query.
Here is the (working) HQL query :
Code:
select user from User user inner join user.Bids bid inner join bid.Item item where item.Name like '%Color%'
Now here is my QBC query :
Code:
ICriteria criteria = session.CreateCriteria(typeof(User))
.CreateCriteria("Bids", JoinType.InnerJoin)
.CreateCriteria("Item", JoinType.InnerJoin)
.Add(Expression.Like("Name", "%Color%").IgnoreCase());
The generated SQL does not contain the second inner join in the criteria version. Is there anything wrong in my query ?
Hibernate version: 1.2.0.3002
Mapping documents:I can include if neededFull stack trace of any exception that occurs:Code:
NHibernate.ADOException: could not execute query
[see generated SQL] ---> Oracle.DataAccess.Client.OracleException ORA-00904: "ITEM2_"."NAME": invalid identifier à Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
à Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
à Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior)
à Oracle.DataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
à System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
à NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
à NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
à NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
à NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
à NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
--- Fin de la trace de la pile d'exception interne ---
à NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
à NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
à NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
à NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session)
à NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
à NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
à NHibernate.Impl.CriteriaImpl.List[T]()
à NHibernate.Impl.CriteriaImpl.Subcriteria.List[T]()
The generated SQL (show_sql=true):Code:
SELECT this_.ID as ID3_1_,
this_.FIRSTNAME as FIRSTNAME3_1_,
this_.LASTNAME as LASTNAME3_1_,
this_.AGE as AGE3_1_,
this_.APP_ID as APP6_3_ 1_,
this_.RATE as RATE3_1_,
this_.STREET as STREET3_1_,
this_.CITY as CITY3_1_,
this_.ZIPCODE as ZIPCODE3_1_,
this_.COUNTRY as COUNTRY3_1_,
this_.USER LEVEL as USERLEVEL3_1_,
this_.TYPE as TYPE1_,
bid1_.USERID as USERID8_0_,
bid1_.ITEMID as ITEMID8_0_,
bid1_.BIDDATE as BIDDATE8_0_,
bid1_.AMOUNT as AM OUNT8_0_
FROM USERS this_, BIDS bid1_
WHERE this_.ID = bid1_.USERID
AND lower(item2_.NAME) like :p0;
:p0 = '%color%'