我对 Hibernate Example 查询有疑问。我如何使用 Hibernate 示例查询进行连接查询。这是我想做的;
Cat cat = new Cat();
cat.setFood(myFoodObject); // Food is another entity that has reference to Cat class.
List results = session.createCriteria(Cat.class)
.add( Example.create(cat) )
.list();
我的美食课;
public class Food {
.....
@OneToMany(cascade = CascadeType.ALL,mappedBy = "food", fetch = FetchType.EAGER)
private List<Cat> catList;
}
我的猫课;
public class Cat{
.....
@JoinColumn(name = "food", referencedColumnName = "id")
@ManyToOne(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
private Food food;
}