代码之家  ›  专栏  ›  技术社区  ›  alamar

如何将项目排序HQL转换为筛选查询?

  •  1
  • alamar  · 技术社区  · 16 年前

    我有一个疑问:

    sess.createQuery("from Box b join b.items bi order by bi.name").list()
    

    天真的尝试:

     sess.createFilter(boxes, "join this.items bi order by bi.name").list()
     sess.createFilter(boxes, "from this join this.items bi order by bi.name").list()
    

    不要工作!

    2 回复  |  直到 9 年前
        1
  •  2
  •   dira    16 年前

    尝试

    session.createFilter(items.getBoxes(), "order by this.name").list()
    
        2
  •  0
  •   ChssPly76    16 年前

    collection filters this 指收藏 要素 .

    你可以这样写:

    sess.createFilter(boxes, "where this.name = ?").list();
    

    也就是说,我在你的例子中没有看到任何条件。我不确定是否 order by @OrderBy

    @OrderBy("name")
    private List items;