title: hibernate QueryException: could not resolve property in spring petclinic sample application
body: <p>I have the following JPA method:  </p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public Collection&lt;Owner&gt; findByPetType(Integer typeID) {
      Query query = this.em.createQuery("SELECT DISTINCT owner FROM Owner owner left join fetch owner.pets as pet WHERE pet.type_id LIKE :typeID");
      query.setParameter("typeID", typeID + "%");
      return query.getResultList();
  }  
  </code></pre>
  
  <p>It is throwing the following error message:  </p>
  
  <pre><code>org.hibernate.QueryException: could not resolve property: type_id of:  
  org.springframework.samples.petclinic.model.Pet [SELECT DISTINCT owner FROM  
  org.springframework.samples.petclinic.model.Owner owner left join fetch owner.pets  
  as pet WHERE pet.type_id LIKE :typeID];  
  nested exception is java.lang.IllegalArgumentException:  
  org.hibernate.QueryException: could not resolve property: type_id of:  
  org.springframework.samples.petclinic.model.Pet [SELECT DISTINCT owner FROM      
  org.springframework.samples.petclinic.model.Owner owner left join fetch owner.pets  
  as pet WHERE pet.type_id LIKE :typeID]  
  </code></pre>
  
  <p>This is from the Spring petclinic sample application, so all relevant code <a href="https://github.com/SpringSource/spring-petclinic/" rel="nofollow">is at this link</a>, including the database definition.  I am using the hsqldb and jpa, the findByPetType() method above is something I wrote, which is not in the sample application.  </p>
  
  <p>Can anyone show me how to fix the code so that it does not produce this error message?  </p>
  
  <p>EDIT:  </p>
  
  <p>I followed Alex's advice and changed pet.type_id to pet.type.  Now it is giving me the following error message (the value of typeID is set to 1):  </p>
  
  <pre><code>Parameter value [1%] did not match expected type  
  [org.springframework.samples.petclinic.model.PetType]; nested exception is  
  java.lang.IllegalArgumentException: Parameter value [1%] did not match expected type  
  [org.springframework.samples.petclinic.model.PetType]  
  </code></pre>
  
  <p>SECOND EDIT:  </p>
  
  <p>I made Sergi Almar's suggestion, and now it is throwing the following error:  </p>
  
  <pre><code>Parameter value [1%] did not match expected type [java.lang.Integer]; nested exception   
  is java.lang.IllegalArgumentException: Parameter value [1%] did not match expected type   
  [java.lang.Integer]  
  </code></pre>
  
  <p>I checked, and the calling code initiates typeID as "Integer typeID = 1;"  So I am not sure why it is not seeing an integer here.</p>