title: Hibernate mapping : HQL many-to-one Query - how to retrieve attributes of crossed pojo objects
body: <p>I'm a beginner using Hibernate 4.3(xml style) and I'm stuck with the way to query when it asks not only the pojo elements. What I mean...(see next example)</p>
  
  <p>I have two tables : Person and Adress.
  In table Person, I have a foreign key 'id_adress_fk' who references the Adress.
  In table Adress, I have an 'id' as primary Key and 'Adress_Street_Name' as attribute.
  One participant can have only one Adress. One adress have several person who lives there.
  I write two Pojos class.</p>
  
  <p>I'm trying to request the database to have Person attributes and Adress Street Name. But I don't get to retrieve the Adress Street Name. I don't understand what object is returned, how to write the good query who matches the good object returned. Do i have to make a join between Adress and Person ? But in this case what is the object returned ? How can I handle this ?</p>
  
  <p>Thanks a lot.</p>
  
  <p><strong>My pojos :</strong></p>
  
  <pre><code>public class Person implements Serializable  {
  
  private Integer id;
  private Adress adress;
  
      // getters and setters
  
  public class Adress implements Serializable {
  
  private Integer id;
  private Set&lt;Person&gt; persons   = new HashSet&lt;Person&gt;(0);
  
      // getters and setters
  </code></pre>
  
  <p><strong>My mappings :</strong></p>
  
  <p>ADRESS.HBM.XML</p>
  
  <pre><code>    &lt;set name="persons" table="person" inverse="true" lazy="false" &gt;
  
          &lt;key&gt;
              &lt;column name="id_adress_fk" not-null="true"  /&gt;
          &lt;/key&gt; 
          &lt;one-to-many class="com.you.know.what.Person" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>PERSON.HBM.XML</p>
  
  <pre><code>    &lt;many-to-one name="adress" class="you.know.what.Adress" &gt;
          &lt;column name="id_adress_fk" not-null="true" /&gt; 
      &lt;/many-to-one&gt;  
  </code></pre>
  
  <p><strong>My query (for instance):</strong></p>
  
  <pre><code> List&lt;Person&gt; allPerson = getSessionFactory().getCurrentSession().createQuery( "from Person ").list();
  </code></pre>
  
  <p>I know i'm querying only the Pojo Person, but the Adress object is 'included' in Person, so i should sucess to retrieve Adress_street_name...A hand on this could be great !</p>