These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: nhibernate learner
PostPosted: Fri Jun 15, 2007 1:25 am 
Newbie

Joined: Fri Jun 15, 2007 1:15 am
Posts: 5
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 !


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 2:26 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Your HQL query is wrong. Look in the documentation, it has lots of examples of HQL queries with joins.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 3:12 am 
Newbie

Joined: Fri Jun 15, 2007 1:15 am
Posts: 5
hm
I 've looked
This supoused to be a simple query i can't figure out where i was wrong


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.