|
Hi all
I 'm trying to do my first steps in nhibernate world.
And i've decided to started with a simple parnet child graph.
I 'm using two tables from Adventure Works database.
For this i'm using Person.Addres and person.StateProv tables.
Here is the part from mappong file that describes that tables and relation ship between them
<class name="StateProv" table="Person.StateProv">
<id name="StateID" column ="StateProvinceID" type="int">
<generator class="identity"/>
</id>
<property name="Name" type="String" />
<property name="StateProvCode" type="String" />
<set name="Adrese" inverse="true">
<key column="AdressID" />
<one-to-many class="Adresa" />
</set>
</class>
<class name="Adresa" table="Person.Adress">
<id name="AdressID" column ="AdressID" type="int">
<generator class="identity"/>
</id>
<property name="AdressLine2" type="String" length="40"/>
<property name="AdressLine1" type="String" length="40"/>
<property name="City" type="String" length="40"/>
<many-to-one name="State" column="StateProvinceID" not-null="true" />
I,m trring to do a simple inner join with hql between that two tables like that:
IQuery query = session.CreateQuery("select state from NHibernate.Examples.QuickStart.StateProv as state inner join NHibernate.Examples.QuickStart.Adresa as adresa");
IList<NHibernate.Examples.QuickStart.StateProv> lista = (IList<NHibernate.Examples.QuickStart.StateProv>)query.List();
foreach (NHibernate.Examples.QuickStart.StateProv obj in lista)
{
Console.WriteLine("Name:%s",obj.Name);
Console.WriteLine("StateProvCode:%s",obj.StateProvCode);
foreach (NHibernate.Examples.QuickStart.Adresa adresa in obj.Adrese)
{
Console.WriteLine("Adresa1:%s", adresa.AdressLine1);
Console.WriteLine("Adresa2:%s", adresa.AdressLine2);
Console.WriteLine("city:%s", adresa.City);
}
The issue is at query.List nhiber nate raise me the next exception:outer or full join must be followed by path expression [select state from NHibernate.Examples.QuickStart.StateProv as state inner join NHibernate.Examples.QuickStart.Adresa as adresa]
Thank you !
|