Transient method returns "could not resolve property".
Code:
public class Me {
private Long id;
private String username;
private Car mycar = new Car();
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@Transient
public Car getMycar() {
return mycar;
}
public void setMycar(Car mycar) {
this.mycar = mycar;
}
}
public class Car {
private Long id;
private String model;
private String mileage;
private String cost;
Assuming all the getter and setters are already coded....
}
The following is my getHibernateTemplate() using HQL.
Code:
public List<Me> findCars(String username, String cost) {
getHibernateTemplate().find("from Me as m where m.username='"+username+"' and m.mycar.cost='"+cost+"'");
}
The following is my error message.
Code:
could not resolve property: mycar of: com.app.model.Me [from com.app.model.Me as m where m.username='jack' and m.mycar.cost='40000']; nested exception is org.hibernate.QueryException: could not resolve property: mycar of: com.app.model.Me [from com.app.model.Me as m where m.username='jack' and m.mycar.cost='40000']
Can anyone help me to resolve this error? Thanks.