I would like to sort (orderBy) a collection of Content objects by the value of one of its associated elements stored in a map.
The Java for the value I want to order by is:
Code:
content.getMetaData().get("netPay").getValue();
Where each part is represented by the following annotation mapped classes:
content: Content
content.getMetaData(): FreeFormRecord extends FreeFromDatabaseObject implements Map
content.getMetaData().get("netPay"): FreeFormField extends FreeFormDatabaseObject implements CharSequence
content.getMetaData().get("netPay").getValue(): String
FreeFormDatabaseObject is the superclass of FreeFormRecord, FreeFormField and the previously unmentioned FreeFormList. The approach allows me to store arbitrary trees of strings stored in the leaves (FreeFormField).
FreeFormRecord actually implements the Map interface via composition - it has the field:
Code:
Map<String,FreeFormDatabaseObject> map = new HashMap<String,FreeFormDatabaseObject>();
In practice one could rewrite the Java as:
Code:
content.getMetaData().getMap().get("netPay").getValue();
How do I do rewrite this in HQL to go in the
Code:
session.createFilter(collection,hql)
method?
I've played with joins and the index() function but I can't get it to work.