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 classstatic interfacestatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Callbacks.SerializableSupplier<javax.persistence.EntityManager>protected JPALazyDataModel.FilterEnricher<T>protected JPALazyDataModel.QueryEnricher<T>protected Callbacks.SerializableConsumer<List<T>>protected Stringprotected Callbacks.SerializableFunction<T,Object> protected Class<?>protected JPALazyDataModel.SortEnricher<T>protected booleanFields inherited from class org.primefaces.model.LazyDataModel
rowKeyConverter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyFilters(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.CriteriaQuery<?> cq, javax.persistence.criteria.Root<T> root, Map<String, FilterMeta> filterBy) protected voidapplyGlobalFilters(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 voidapplySort(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()intcount(Map<String, FilterMeta> filterBy) Counts the all available data for the given filters.protected javax.persistence.criteria.PredicatecreatePredicate(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 StringgetStringFilterValue(Object filterValue, Locale locale) Loads the data for the given parameters.protected javax.persistence.criteria.ExpressionresolveFieldExpression(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, setWrappedDataMethods inherited from class javax.faces.model.DataModel
addDataModelListener, getDataModelListeners, removeDataModelListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:LazyDataModelCounts 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 bothrowCountanddatawithin 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:
countin 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:LazyDataModelLoads the data for the given parameters.- Specified by:
loadin 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:
getRowDatain interfaceSelectableDataModel<T>- Overrides:
getRowDatain classLazyDataModel<T>
-
getRowKey
- Specified by:
getRowKeyin interfaceSelectableDataModel<T>- Overrides:
getRowKeyin classLazyDataModel<T>
-
builder
-