Package org.kiwiproject.beta.dao
Class DaoHelpers
java.lang.Object
org.kiwiproject.beta.dao.DaoHelpers
Some simple utilities useful to data access code that is building queries,
for example, structured query languages such as SQL or HQL.
This is useful in situations where you have a relatively static query, but you need to add dynamically defined sorting/ordering.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddSort(StringBuilder query, AllowedFields allowedSortFields, String sortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction sortDirection) Add a sort to the query restricting by theAllowedFieldsfor the sort field and direction.static voidaddSort(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort sort) Add a sort to the query restricting by theAllowedFieldsfor theKiwiSort.static voidaddSorts(StringBuilder query, AllowedFields allowedSortFields, @Nullable String primarySortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction primarySortDirection, @Nullable String secondarySortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction secondarySortDirection) Add sorts to the query restricting by theAllowedFieldsfor the primary and secondary sort fields and directions.static voidaddSorts(StringBuilder query, AllowedFields allowedSortFields, List<org.kiwiproject.spring.data.KiwiSort> sorts) Adds sorts to the query restricting by theAllowedFieldsfor all the specified sorts.static voidaddSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort... sorts) Adds sorts to the query restricting by theAllowedFieldsfor all the specified sorts.static voidaddSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort primarySort, org.kiwiproject.spring.data.KiwiSort secondarySort) Add sorts to the query restricting by theAllowedFieldsfor the primary and secondary sort criteria.static voidaddSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.PagingRequest pagingRequest) Add sorts to the query restricting by theAllowedFieldsfor thePagingRequest.
-
Method Details
-
addSorts
public static void addSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.PagingRequest pagingRequest) Add sorts to the query restricting by theAllowedFieldsfor thePagingRequest. -
addSort
public static void addSort(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort sort) Add a sort to the query restricting by theAllowedFieldsfor theKiwiSort. -
addSort
public static void addSort(StringBuilder query, AllowedFields allowedSortFields, String sortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction sortDirection) Add a sort to the query restricting by theAllowedFieldsfor the sort field and direction. -
addSorts
public static void addSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort primarySort, org.kiwiproject.spring.data.KiwiSort secondarySort) Add sorts to the query restricting by theAllowedFieldsfor the primary and secondary sort criteria. -
addSorts
public static void addSorts(StringBuilder query, AllowedFields allowedSortFields, @Nullable String primarySortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction primarySortDirection, @Nullable String secondarySortField, @Nullable org.kiwiproject.spring.data.KiwiSort.Direction secondarySortDirection) Add sorts to the query restricting by theAllowedFieldsfor the primary and secondary sort fields and directions.This allows for the possibility that there are no sort criteria, in which case the query is not modified.
- Implementation Note:
- If a secondary sort is specified but not a primary sort, then a warning is logged, the secondary sort is ignored, and therefore the query is not modified.
-
addSorts
public static void addSorts(StringBuilder query, AllowedFields allowedSortFields, org.kiwiproject.spring.data.KiwiSort... sorts) Adds sorts to the query restricting by theAllowedFieldsfor all the specified sorts.This allows for the possibility that there are no sort criteria, in which case the query is not modified.
- Implementation Note:
- Any null values in the
sortsarray are filtered out
-
addSorts
public static void addSorts(StringBuilder query, AllowedFields allowedSortFields, List<org.kiwiproject.spring.data.KiwiSort> sorts) Adds sorts to the query restricting by theAllowedFieldsfor all the specified sorts.This allows for the possibility that there are no sort criteria, in which case the query is not modified.
- Implementation Note:
- Any null values in the
sortslist are filtered out
-