title: NHibernate - simple join query
body: <p>A very simple scenario.
  I have 2 classes: <strong><em>Project</em></strong> and <strong><em>DataStructure</em></strong>. Class <strong><em>Project</em></strong> contains member List&lt;<strong><em>DataStructure</em></strong>>. 
  My goal is to load a Project and all its DataStructures in one call.</p>
  
  <pre><code>public class Project
  {
      public virtual string Id { get { } set { } }
      public virtual string Name { get { } set { } }
      public virtual ISet&lt;DataStructure&gt; DataStructures { get { } set { } }
  }
  
  public class DataStructure
  {
      public virtual string Id { get { } set { } }
      public virtual string Name { get { } set { } }
      public virtual string Description { get { } set { } }
      public virtual Project Project { get { } set { } }
      public virtual IList&lt;DataField&gt; Fields { get { } set { } }
  }
  </code></pre>
  
  <p>Note that <strong><em>DataStructure</em></strong> also contains a list of class <strong><em>DataField</em></strong> but I don’t want to load these right now.</p>
  
  <p>Mapping in Fluent NHibernate:</p>
  
  <pre><code>public class ProjectMap : ClassMap&lt;Project&gt;
  {
      public ProjectMap()
      {
          Table("PROJECTS");
          Id(x =&gt; x.Pk, "PK");
          Map(x =&gt; x.Id, "ID");
          Map(x =&gt; x.Name, "NAME");
          HasMany&lt;DataStructure&gt;(x =&gt; x.DataStructures).KeyColumn("FK_PROJECT");
      }
  }
  
  public class DataStructureMap : ClassMap&lt;DataStructure&gt;
  {
      public DataStructureMap()
      {
          Table("DATA_STRUCTURES");
          Map(x =&gt; x.Id, "ID");
          Map(x =&gt; x.Name, "NAME");
          Map(x =&gt; x.Description, "DESCRIPTION");
          References&lt;Project&gt;(x =&gt; x.Project, "FK_PROJECT");
          HasMany&lt;DataField&gt;(x =&gt; x.Fields).KeyColumn("FK_DATA_STRUCTURE");
      }
  }
  </code></pre>
  
  <p>This is my query:</p>
  
  <pre><code>using (ISession session = SessionFactory.OpenSession())
  {
      IQuery query = session.CreateQuery("from Project left join DataStructure");
      project = query.List&lt;Project&gt;();
  }
  </code></pre>
  
  <p>The result is this exception:</p>
  
  <pre><code>NHibernate.Hql.Ast.ANTLR.SemanticException: Path expected for join! [from Themis.DataEntities.Project left join DataStructure]
  </code></pre>
  
  <p>Do I need to specify the field for the join? Isn’t that inferred from the mappings?</p>
  
  <p>Note1 – Table <strong><em>PROJECTS</em></strong> contains a single <strong><em>Project</em></strong> row so there is no need to search for a specific one. </p>
  
  <p>Note2 – I verified that my NHibernate setup is correct by successfully loading just the <strong><em>Project</em></strong>.</p>