0

我对 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;
}
4

1 回答 1

0

示例查询的文档说:

版本属性、标识符和关联被忽略。

(强调我的)

于 2013-06-03T11:46:15.067 回答