Package org.primefaces.model
Class JPALazyDataModel<T>
java.lang.Object
javax.faces.model.DataModel<T>
org.primefaces.model.LazyDataModel<T>
org.primefaces.model.JPALazyDataModel<T>
- Type Parameters:
T
- The model class.
- All Implemented Interfaces:
Serializable
,Iterable<T>
,SelectableDataModel<T>
Basic
LazyDataModel
implementation with JPA and Criteria API.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
static interface
static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected Callbacks.SerializableSupplier<javax.persistence.EntityManager>
protected JPALazyDataModel.FilterEnricher<T>
protected JPALazyDataModel.QueryEnricher<T>
protected Callbacks.SerializableConsumer<List<T>>
protected String
protected Callbacks.SerializableFunction<T,
Object> protected Class<?>
protected JPALazyDataModel.SortEnricher<T>
protected boolean
Fields inherited from class org.primefaces.model.LazyDataModel
rowKeyConverter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
applyFilters
(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.CriteriaQuery<?> cq, javax.persistence.criteria.Root<T> root, Map<String, FilterMeta> filterBy) 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) Deprecated.use the builder and filterEnricher insteadprotected void
applySort
(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.CriteriaQuery<T> cq, javax.persistence.criteria.Root<T> root, Map<String, SortMeta> sortBy) static <T> JPALazyDataModel.Builder<T>
builder()
int
count
(Map<String, FilterMeta> filterBy) Counts the all available data for the given filters.protected javax.persistence.criteria.Predicate
createPredicate
(FilterMeta filter, PropertyDescriptor pd, javax.persistence.criteria.Root<T> root, javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Expression fieldExpression, Object filterValue, Locale locale) getRowData
(String rowKey) protected String
getStringFilterValue
(Object filterValue, Locale locale) Loads the data for the given parameters.protected javax.persistence.criteria.Expression
resolveFieldExpression
(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.CriteriaQuery<?> cq, javax.persistence.criteria.Root<T> root, String fieldName) Methods inherited from class org.primefaces.model.LazyDataModel
getMessage, getPageSize, getRowCount, getRowData, getRowIndex, getRowKeyFromConverter, getWrappedData, isRowAvailable, iterator, iterator, loadOne, recalculateFirst, setPageSize, setRowCount, setRowIndex, setWrappedData
Methods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, removeDataModelListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
entityClass
-
rowKeyField
-
caseSensitive
protected boolean caseSensitive -
wildcardSupport
protected boolean wildcardSupport -
rowKeyType
-
queryEnricher
-
filterEnricher
-
sortEnricher
-
entityManager
-
rowKeyProvider
-
resultEnricher
-
-
Constructor Details
-
JPALazyDataModel
public JPALazyDataModel()For serialization only
-
-
Method Details
-
count
Description copied from class:LazyDataModel
Counts the all available data for the given filters. In case of SQL, this would execute a "SELECT COUNT ... WHERE ...". In case you dont use SQL and receive bothrowCount
anddata
within a single call, this method should just return0
. You must callLazyDataModel.recalculateFirst(int, int, int)
andLazyDataModel.setRowCount(int)
in yourLazyDataModel.load(int, int, java.util.Map, java.util.Map)
method.- Specified by:
count
in classLazyDataModel<T>
- Parameters:
filterBy
- a map with all filter information (only relevant for DataTable, not for eg DataView)- Returns:
- the data count
-
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 classLazyDataModel<T>
- Parameters:
first
- the first entrypageSize
- the page sizesortBy
- 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
@Deprecated 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) Deprecated.use the builder and filterEnricher instead -
createPredicate
protected javax.persistence.criteria.Predicate createPredicate(FilterMeta filter, PropertyDescriptor pd, javax.persistence.criteria.Root<T> root, javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Expression fieldExpression, Object filterValue, Locale locale) -
getStringFilterValue
-
applySort
-
resolveFieldExpression
-
getRowData
- Specified by:
getRowData
in interfaceSelectableDataModel<T>
- Overrides:
getRowData
in classLazyDataModel<T>
-
getRowKey
- Specified by:
getRowKey
in interfaceSelectableDataModel<T>
- Overrides:
getRowKey
in classLazyDataModel<T>
-
builder
-