hibernate QueryException: could not resolve property in spring petclinic
sample application
I have the following JPA method:
@SuppressWarnings("unchecked")
public Collection<Owner> 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();
}
It is throwing the following error message:
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]
This is from the Spring petclinic sample application, so all relevant code
is at this link, 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.
Can anyone show me how to fix the code so that it does not produce this
error message?
No comments:
Post a Comment