【问题标题】:Hibernate Criteria Example query休眠条件示例查询
【发布时间】:2013-06-03 09:12:30
【问题描述】:

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

【问题讨论】:

    标签: hibernate persistence hibernate-criteria


    【解决方案1】:

    The documentation for Example queries 说:

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

    (强调我的)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-08
      • 2011-06-06
      • 2011-04-13
      • 2017-03-21
      • 1970-01-01
      相关资源
      最近更新 更多