Appearance
@SortingExpression
The @SortingExpression annotation defines the default sorting behavior for an entity or field. It uses the same ${fieldName} placeholder syntax as @DisplayFormat.
Usage on Entities
java
@SortingExpression("${name}")
@SquizyEntity
@Entity
public class Category { /* ... */ }This is equivalent to using the sortingExpression attribute on @SquizyEntity:
java
@SquizyEntity(sortingExpression = "${name}")
@Entity
public class Category { /* ... */ }The sorting expression applies to all queries — dropdowns, relationship lists, and table views — unless overridden by @DefaultTableSortingExpression for the table view specifically.
ID is always appended as last sort criterion
To guarantee deterministic ordering for pagination and streaming, the entity's ID field is always appended as the final sorting criterion. This ensures that records with identical sorting values are returned in a stable, reproducible order.
Usage on Fields
Override the sorting expression for a specific relationship field:
java
@SortingExpression("${name}")
@ManyToOne
private City city;This controls how the City column is sorted in the parent entity's table. This is equivalent to using @SquizyField(sortingExpression = ...).
Attributes
value
The sorting expression using ${fieldName} placeholders:
java
@SortingExpression("${lastName} ${firstName}")descending
When true, the default sort order is descending:
java
@SortingExpression(value = "${createdDate}", descending = true)Related
@DefaultTableSortingExpression— overrides sorting specifically for the table view@SquizyEntity— thesortingExpressionattribute@SquizyField— field-level sorting expression