public class JpaGridDataSource<E> extends Object implements GridDataSource
GridDataSource
based on a
EntityManager and a known
entity class. This implementation does support multiple
sort
constraints
.
This class is not thread-safe; it maintains internal state.
Typically, an instance of this object is created fresh as needed (that is, it is not stored
between requests).Constructor and Description |
---|
JpaGridDataSource(EntityManager entityManager,
Class<E> entityType) |
Modifier and Type | Method and Description |
---|---|
protected void |
applyAdditionalConstraints(CriteriaQuery<?> criteria,
Root<E> root,
CriteriaBuilder builder) |
int |
getAvailableRows()
Returns the number of rows available in the data source.
|
Class<E> |
getRowType()
Returns the type of value in the rows, or null if not known.
|
Object |
getRowValue(int index)
Returns the row value at the provided index.
|
void |
prepare(int startIndex,
int endIndex,
List<SortConstraint> sortConstraints)
Invoked to allow the source to prepare to present values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAvailableRows, isEmpty
public JpaGridDataSource(EntityManager entityManager, Class<E> entityType)
public int getAvailableRows()
getAvailableRows
in interface GridDataSource
public void prepare(int startIndex, int endIndex, List<SortConstraint> sortConstraints)
prepare
in interface GridDataSource
startIndex
- the starting index to be retrievedendIndex
- the ending index to be retrievedsortConstraints
- identify how data is to be sortedprotected void applyAdditionalConstraints(CriteriaQuery<?> criteria, Root<E> root, CriteriaBuilder builder)
public Object getRowValue(int index)
GridDataSource.getAvailableRows()
may return a different number of rows than are actually available (i.e., the database
was changed between calls to GridDataSource.getAvailableRows()
and the call to GridDataSource.prepare(int, int,
java.util.List)
). In that case, this method should return null for any out-of-range indexes.getRowValue
in interface GridDataSource
public Class<E> getRowType()
BeanModel
when no such model is explicitly provided.getRowType
in interface GridDataSource
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.