outer or full join must be followed by path expression

1,928 views
Skip to first unread message

Zafar Ullah

unread,
Jul 11, 2008, 10:26:21 AM7/11/08
to nhusers
I am getting this exception

NHibernate.QueryException: in expected: w [select from
AM.Library.AMOperator op inner join AMWell w on w.OperatorId = op.Id
]
at NHibernate.Hql.FromParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator
q)
at NHibernate.Hql.PreprocessingParser.Token(String token,
QueryTranslator q)
at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String
seperators, QueryTranslator q)
at NHibernate.Hql.QueryTranslator.Compile()
at
NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor
factory, IDictionary replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString,
Boolean shallow) at
Ayende.NHibernateQueryAnalyzer.Model.Project.HqlToSql(String hqlQuery,
IDictionary parameters)
at
Ayende.NHibernateQueryAnalyzer.UserInterface.Presenters.QueryPresenter.TranslateHql()



My CODE
========

Emp table has an operatorid which comes from a Lookup table name
tblOperator

QueryService qs = new QueryService();

string query = "select e.Name from AM.Library.Emp e inner join
AM.Library.Operator op on e.OperatorId = op.Id ";

IList list = qs.ExecHQLQuery(query, 0);



Here is my QueryService Class snippet i used to execute above query

using (ISession session = sessionFactory.OpenSession())
{
IList list = session.Find(query);
return list;
}


I am fedup of this please help.

Markus Zywitza

unread,
Jul 12, 2008, 10:20:05 AM7/12/08
to nhu...@googlegroups.com
GMail HQL:
select e.Name from AM.Library.Emp e inner join fetch e.OperatorId

Assuming that OperatorId is the _Property_ name, not the column name.

-Markus

Zafar Ullah

unread,
Jul 15, 2008, 3:53:25 AM7/15/08
to nhusers
Murkus,
i think i didnt convey you full information because mapping file is
missing in my post. Please add this info along with above given info

My Query

select w.WellName from AM.Library.AMWell as w inner join
AM.Library.AMOperator op on w.OperatorId = op.Id

OR

select w.WellName from AM.Library.AMWell as w inner join
AM.Library.AMOperator op on w.Operator.Id = op.Id

OR

select w.WellName from AM.Library.AMWell as w inner join
AM.Library.AMOperator op where w.OperatorId = op.Id

This is the exception that i got in both ways

NHibernate.QueryException: outer or full join must be followed by path
expression [select w.WellName from AM.Library.AMWell as w inner join
AM.Library.AMOperator op on w.OperatorId = op.Id
]
at NHibernate.Hql.FromParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
at NHibernate.Hql.PreprocessingParser.Token(String token,
QueryTranslator q)
at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String
seperators, QueryTranslator q)
at NHibernate.Hql.QueryTranslator.Compile()
at NHibernate.Hql.QueryTranslator.Compile(ISessionFactoryImplementor
factory, IDictionary replacements, Boolean scalar)
at NHibernate.Impl.SessionFactoryImpl.GetQuery(String queryString,
Boolean shallow) at
Ayende.NHibernateQueryAnalyzer.Model.Project.HqlToSql(String hqlQuery,
IDictionary parameters)
at
Ayende.NHibernateQueryAnalyzer.UserInterface.Presenters.QueryPresenter.TranslateHql()



Here is my mapping file


<class name="AM.Library.AMWell, AM.Library" table="AM_Well">
<id name="WellId" column="WellId">
<generator class="identity" />
</id>
<property name="WellName" column="WellName" />
<property name="OperatorId" column="OperatorId" />
<property name="WellNumber" column="WellNumber" />
<many-to-one name="Operator" class="AM.Library.AMOperator, AM.Library"
column="OperatorId" cascade="none" update="false" insert="false" />
</class>


<class name="AM.Library.AMOperator, AM.Library" table="ET_Operator">
<id name="Id" column="ID">
<generator class="assigned" />
</id>
<property name="Name" column="OperatorID" />
<property name="Remarks" column="Operator" />
</class>



I am using NHibernate version 1.0.2, Windowx XP, .net 2.0, sqlserver
2005 express


many thanks in advance

Zafar Ullah

Markus Zywitza

unread,
Jul 15, 2008, 5:26:07 AM7/15/08
to nhu...@googlegroups.com
select e.Name from AMWell e inner join fetch e.Operator

Remember, HQL is not SQL and works on Entities, not tables. You must
use property names, not column names, and you must join on objects
paths, not on relations.

select w.WellName from AM.Library.AMWell as w inner join
AM.Library.AMOperator op where w.OperatorId = op.Id

tranlates into

select w.WellName from AM.Library.AMWell as w join
w.Operator

NHibernate can follow the mapped relations by itself. Please read this again:
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/queryhql.html

-Markus

Reply all
Reply to author
Forward
0 new messages