Class JpaGridDataSource<E>

  • All Implemented Interfaces:
    GridDataSource

    public class JpaGridDataSource<E>
    extends java.lang.Object
    implements GridDataSource
    A simple implementation of 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).
    Since:
    5.3
    • Constructor Summary

      Constructors 
      Constructor Description
      JpaGridDataSource​(javax.persistence.EntityManager entityManager, java.lang.Class<E> entityType)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void applyAdditionalConstraints​(javax.persistence.criteria.CriteriaQuery<?> criteria, javax.persistence.criteria.Root<E> root, javax.persistence.criteria.CriteriaBuilder builder)  
      int getAvailableRows()
      Returns the number of rows available in the data source.
      java.lang.Class<E> getRowType()
      Returns the type of value in the rows, or null if not known.
      java.lang.Object getRowValue​(int index)
      Returns the row value at the provided index.
      void prepare​(int startIndex, int endIndex, java.util.List<SortConstraint> sortConstraints)
      Invoked to allow the source to prepare to present values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JpaGridDataSource

        public JpaGridDataSource​(javax.persistence.EntityManager entityManager,
                                 java.lang.Class<E> entityType)
    • Method Detail

      • prepare

        public void prepare​(int startIndex,
                            int endIndex,
                            java.util.List<SortConstraint> sortConstraints)
        Invoked to allow the source to prepare to present values. This gives the source a chance to pre-fetch data (when appropriate) and informs the source of the desired sort order. Sorting comes first, then extraction by range.
        Specified by:
        prepare in interface GridDataSource
        Parameters:
        startIndex - the starting index to be retrieved
        endIndex - the ending index to be retrieved
        sortConstraints - identify how data is to be sorted
      • applyAdditionalConstraints

        protected void applyAdditionalConstraints​(javax.persistence.criteria.CriteriaQuery<?> criteria,
                                                  javax.persistence.criteria.Root<E> root,
                                                  javax.persistence.criteria.CriteriaBuilder builder)
      • getRowType

        public java.lang.Class<EgetRowType()
        Returns the type of value in the rows, or null if not known. This value is used to create a default BeanModel when no such model is explicitly provided.
        Specified by:
        getRowType in interface GridDataSource
        Returns:
        the row type, or null