title: Java Hibernate Transformer AliasToBeanNestedResultTransformer
body: <p>i have a query like this. i pass the student ID i need some fields from Student as well as their parent as well some fields from the parent->Address[here is the main problem i am facing] i am using <code>AliasToBeanNestedResultTransformer</code> transformer by <a href="https://stackoverflow.com/users/1129044/sami-andoni">Sami Andoni</a> </p>
  
  <p>here is the implementation of it <a href="https://github.com/samiandoni/AliasToBeanNestedResultTransformer/blob/master/AliasToBeanNestedResultTransformer.java" rel="nofollow noreferrer">CODE</a></p>
  
  <p>here is my code.</p>
  
  <pre><code>public List&lt;Student&gt;searchForStudent(Integer studentId)
  {           
      Projection p=Projections.projectionList().create()
      .add(Projections.property("name"),"name")//the student name it works O.K
      .add(Projections.property("lastname"),"lastname")//the student name it works O.K
      .add(Projections.property("age"),"age")//the student AGE it works O.K                
      .add(Projections.property("p.phone"),"parent.phone")//the parent phone it works O.K                
      .add(Projections.property("address.state").as("parent.Address.state")); // i need a field from address.state here is the problem...  
      Session session = ......
      Criteria like = session.createCriteria(Student.class).add(prepareForSelect())//some filters..
      .createAlias("parent","p")//the parent of the student. a student have one parent
      .createAlias("parent.Address","address")//the address of the parent.... a parent have one address.
      .setProjection(p)                
      .setResultTransformer(new AliasToBeanNestedResultTransformer(Student.class));    
      List&lt;Student&gt;results=like.list();   
      return results;     
  }         
  </code></pre>
  
  <p>it throws </p>
  
  <pre><code>Exception in thread "main" org.hibernate.PropertyAccessException:   IllegalArgumentException occurred while calling setter of com.generic.model.Parent.Address
  </code></pre>
  
  <p>FYI is some type mismatch i have done some tracing in <code>SAMI</code> code and i see this </p>
  
  <pre><code>[MyState]
  [Address]
  </code></pre>
  
  <p>seems that Hibernate is returning a <code>String State</code> <code>MyState</code> in this case  and the transformer is using a <code>Address Object</code> and this is the <code>type Mismatch.</code></p>
  
  <p>is any help is hugely needed it</p>
  
  <p>thanks a lot.</p>