Class AbstractPagingAndSortingRepositoryImpl

  • Direct Known Subclasses:
    JdbiRepositoryImpl

    public abstract class AbstractPagingAndSortingRepositoryImpl
    extends Object
    Convenience repository implementation to be inherited from if applicable.

    Tries best to translate paging and sorting params into valid SQL.
    If result does not fit your use case: implement it yourself and do not use these convenience methods.

    • Field Detail

      • offsetForAlternativePaging

        protected int offsetForAlternativePaging
    • Constructor Detail

      • AbstractPagingAndSortingRepositoryImpl

        public AbstractPagingAndSortingRepositoryImpl()
    • Method Detail

      • addOrderBy

        protected void addOrderBy​(de.digitalcollections.model.list.paging.PageRequest pageRequest,
                                  StringBuilder sqlQuery)
      • addPageRequestParams

        public void addPageRequestParams​(de.digitalcollections.model.list.paging.PageRequest pageRequest,
                                         StringBuilder sqlQuery)
      • getAllowedOrderByFields

        protected abstract List<String> getAllowedOrderByFields()
        Returns:
        model properties names that are applicable for sorting, will be mapped to database column names using @see #getColumnName
      • getColumnName

        public abstract String getColumnName​(String modelProperty)
        Parameters:
        modelProperty - name of model property passed as String, e.g. "lastModified"
        Returns:
        full qualified column name as used in sql queries ("last_modified" or e.g. "w.last_modified" if prefix used in queries)
      • getOrderBy

        public String getOrderBy​(de.digitalcollections.model.list.sorting.Sorting sorting)
      • getUniqueField

        protected abstract String getUniqueField()
        Returns:
        name of model property that guarantees an unique sorting, e.g. a db primary key or another unique column/field
      • supportsCaseSensitivityForProperty

        protected abstract boolean supportsCaseSensitivityForProperty​(String modelProperty)
        Returns whether the passed property can be sorted case sensitive (in general). This method should be kept in sync with getAllowedOrderByFields().
        Parameters:
        modelProperty - the property name (similar to getColumnName(java.lang.String))
        Returns:
        true only if case (in)sensitive sorting is possible