Class JpaLazyDataModel<T>

    • Field Detail

      • entityClass

        protected Class<T> entityClass
      • rowKeyField

        protected String rowKeyField
    • Constructor Detail

      • JpaLazyDataModel

        public JpaLazyDataModel()
        For serialization only
      • JpaLazyDataModel

        public JpaLazyDataModel​(Class<T> entityClass,
                                SerializableSupplier<javax.persistence.EntityManager> entityManager)
        Constructs a JpaLazyDataModel for usage without enabled selection.
        Parameters:
        entityClass - The entity class
        entityManager - The EntityManager
      • JpaLazyDataModel

        public JpaLazyDataModel​(Class<T> entityClass,
                                SerializableSupplier<javax.persistence.EntityManager> entityManager,
                                String rowKeyField)
        Constructs a JpaLazyDataModel with selection support.
        Parameters:
        entityClass - The entity class
        entityManager - The EntityManager
        rowKeyField - The name of the rowKey property (e.g. "id")
      • JpaLazyDataModel

        public JpaLazyDataModel​(Class<T> entityClass,
                                SerializableSupplier<javax.persistence.EntityManager> entityManager,
                                javax.faces.convert.Converter converter)
        Constructs a JpaLazyDataModel with selection support, with an already existing Converter.
        Parameters:
        entityClass - The entity class
        entityManager - The EntityManager
        converter - The converter, which will be used for converting the entity to a rowKey and vice versa
    • Method Detail

      • load

        public List<T> load​(int first,
                            int pageSize,
                            Map<String,​SortMeta> sortBy,
                            Map<String,​FilterMeta> filterBy)
        Description copied from class: LazyDataModel
        Loads the data for the given parameters.
        Specified by:
        load in class LazyDataModel<T>
        Parameters:
        first - the first entry
        pageSize - the page size
        sortBy - a map with all sort information (only relevant for DataTable, not for eg DataView)
        filterBy - a map with all filter information (only relevant for DataTable, not for eg DataView)
        Returns:
        the data
      • applyFilters

        protected void applyFilters​(javax.persistence.criteria.CriteriaBuilder cb,
                                    javax.persistence.criteria.CriteriaQuery<?> cq,
                                    javax.persistence.criteria.Root<T> root,
                                    Map<String,​FilterMeta> filterBy)
      • applyGlobalFilters

        protected void applyGlobalFilters​(Map<String,​FilterMeta> filterBy,
                                          javax.persistence.criteria.CriteriaBuilder cb,
                                          javax.persistence.criteria.CriteriaQuery<?> cq,
                                          javax.persistence.criteria.Root<T> root,
                                          List<javax.persistence.criteria.Predicate> predicates)
      • createPredicate

        protected <F extends Comparable> javax.persistence.criteria.Predicate createPredicate​(FilterMeta filter,
                                                                                              Field filterField,
                                                                                              javax.persistence.criteria.Root<T> root,
                                                                                              javax.persistence.criteria.CriteriaBuilder cb,
                                                                                              javax.persistence.criteria.Expression fieldExpression,
                                                                                              F filterValue)
      • applySort

        protected void applySort​(javax.persistence.criteria.CriteriaBuilder cb,
                                 javax.persistence.criteria.CriteriaQuery<T> cq,
                                 javax.persistence.criteria.Root<T> root,
                                 Map<String,​SortMeta> sortBy)
      • resolveFieldExpression

        protected javax.persistence.criteria.Expression resolveFieldExpression​(javax.persistence.criteria.CriteriaBuilder cb,
                                                                               javax.persistence.criteria.CriteriaQuery<?> cq,
                                                                               javax.persistence.criteria.Root<T> root,
                                                                               String fieldName)
      • convertToType

        protected <V> V convertToType​(String value,
                                      Class<V> valueType)
      • getRowKeyGetter

        protected Method getRowKeyGetter()