kaka_xia
2009-09-19 13:40
浏览 242
已采纳

Hibernate Criteria 多层次查询关联问题

[code="java"]
class House{
private string houseid;
private string housename;
}
class Shelf{
private string shelfid;
private House house;
}
class Position{
private string positionid;
private Shelf shelf;
}
class Warehouse{
private string warehouseid;
private Position position;
}
[/code]

只用QBC能不能这样类似的解决呢?
[quote]
Criteria criteria = BaseUtil.getCriteria(Warehouse.class);

criteria.add(Expression.eq("position.shelf.house.houseid", "111"));

[/quote]
[b]问题补充:[/b]

  1. Criteria criteria = BaseUtil.getCriteria(Warehouse.class);
  2. CriteriaUtil.addAlias((CriteriaImpl)criteria, "position", "position");
  3. CriteriaUtil.addAlias((CriteriaImpl)criteria, "position.shelf", "shelf");
  4. criteria.add(Expression.eq("shelf.house.houseid", "111"));

这个不要贴了 我看过了 觉得麻烦才问的

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题