Sortexpr (attribute of property)

From JRapid

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.

Contents

Usage

 <property
                ...
                collection =  "sortedset"
                sortexpr = SORT_EXPRESSION
                embedded = "inline" | "detail"
 	        ...
 />

Example

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

More

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.

Caution

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