Hello!
I have such problem with criteria query:
I have the following entities:
Code:
@Entity
@Table(name="vacancies")
public class Vacancy {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private Long id;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private VacancyCity city;
/* Getters and setters located at bottom */
}
@Entity
@Table(name="vacancies_cities")
public class VacancyCity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="id")
private Long id;
@Column(name="title")
private String title;
/* Getters and setters located at bottom */
}
But why when I do criteria query with restrictions class I get such exception: Exception in thread "main" org.hibernate.QueryException: could not resolve property: city.title of: np.data.models.Vacancy
Query:
Code:
session.createCriteria(np.data.models.Vacancy.class).add(Restrictions.eq("city.title", "New york")).list();
Thank you!