Question: I have this query:

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

```

It works fine.
However, I have a hibernate's Collection boxes and want to filter is.
Naive tries:

```
 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()

```

don't work!

What's the proper way to convert this HQL to filter?

Answer: 
Try...

```
session.createFilter(items.getBoxes(), "order by this.name").list()

```
When writing [collection filters](http://docs.jboss.org/hibernate/stable/core/reference/en/html/objectstate.html#objectstate-filtering), `this` refers to collection **element**.

You can write something like:

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

```

That said, I don't see any conditions in your example. I'm not sure whether `order by` is allowed in collection filters (haven't tried it), but if all you want to do is sort collection elements you can specify sort order via [@OrderBy](http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html#entity-mapping-association-collections) annotation:

```
@OrderBy("name")
private List items;

```