Sortexpr (attribute of property)

From JRapid

(Redirected from Sortexpr)
Jump to: navigation, search

The sortexpr attribute is used in properties that have the collection attribute set to sortedset and also the embedded attribute set to any of it‘s options. Sortexpr specifies expression to order by.

Sortexpr must be defined in EL. Variables that can be used in the expression are 'now', 'userId' and 'obj', which refers to the object that must be sorted.



                collection =  "sortedset"
                sortexpr = SORT_EXPRESSION
                embedded = "inline" | "detail"


 <property collection="sortedset" entity="User" label="My Friends" labelposition="top"
 name="friends" embedded="inline" sortexpr="obj.firstName" subset="myFriends"/>


When using the "sortexpr" attribute, a class that implements java.util.Comparator is created and is indicated to Hibernate to use it in the "sort" attribute of this property.


  • sortexpr doesn't work with collection of non-entity items.
Personal tools