title: Spring Hibernate: SQLQuery involving mapped entities
body: <p>I have Hibernate generated classes that contain other classes - </p>
  
  <pre><code>public class BookLoans implements java.io.Serializable {
      private BookLoansId id;
      private Borrower borrower;
      private LibraryBranch libraryBranch;
      private Book book;
      private Date dateOut;
      private Date dueDate;
  }
  </code></pre>
  
  <p>where BookLoansId is - </p>
  
  <pre><code>public class BookLoansId implements java.io.Serializable {
  private int bookId;
  private int branchId;
  private int cardNo;
  }
  </code></pre>
  
  <p>which are primary keys in the tables Book, LibraryBranch and Borrower respectively. When I run this query - </p>
  
  <pre><code>sessionFactory.getCurrentSession().createSQLQuery(
      "select * from library.tbl_book_loans l where cardNo = 4");
  </code></pre>
  
  <p>Hibernate returns a list of Object[] elements. If I try to iterate through this list, I get null objects. I've tried a couple of different methods from <a href="http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/querysql.html" rel="nofollow">here</a> and <a href="http://wordgraphs.com/post/3906/Native-SQL-queries-in-Hibernate" rel="nofollow">here</a>.</p>
  
  <p>Is there any way to find out how the objects are arranged within each Object[]?</p>