Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tapestry5.hibernate
Class HibernateGridDataSource

    java.lang.Object
      org.apache.tapestry5.hibernate.HibernateGridDataSource

All Implemented Interfaces:
  GridDataSource

    public class HibernateGridDataSource

extends java.lang.Object
implements GridDataSource

A simple implementation of `GridDataSource` based on a Hibernate Session and a known entity class. This implementation does support multiple `sort constraints`; however it assumes a direct mapping from sort constraint property to Hibernate property.

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 Summary
`HibernateGridDataSource(org.hibernate.Session session, java.lang.Class entityType)`

Method Summary
`protected void` | `applyAdditionalConstraints(org.hibernate.Criteria crit)` Invoked after the main criteria has been set up (firstResult, maxResults and any sort contraints).
`int` | `getAvailableRows()` Returns the total number of rows for the configured entity type.
`java.lang.Class` | `getRowType()` Returns the entity type, as provided via the constructor.
`java.lang.Object` | `getRowValue(int index)` Returns a row value at the given index (which must be within the range defined by the call to `prepare(int, int, java.util.List)` ).
`void` | `prepare(int startIndex, int endIndex, java.util.List<SortConstraint> sortConstraints)` Prepares the results, performing a query (applying the sort results, and the provided start and end index).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HibernateGridDataSource

    public HibernateGridDataSource(org.hibernate.Session session,
                                   java.lang.Class entityType)

Method Detail

### getAvailableRows

    public int getAvailableRows()

  Returns the total number of rows for the configured entity type.

  Specified by:
    `getAvailableRows` in interface `GridDataSource`

### prepare

    public void prepare(int startIndex,
                        int endIndex,
                        java.util.List<SortConstraint> sortConstraints)

  Prepares the results, performing a query (applying the sort results, and the provided start and end index). The results can later be obtained from `getRowValue(int)` }.

  Specified by:
    `prepare` in interface `GridDataSource`
  Parameters:
    `startIndex` - index, from zero, of the first item to be retrieved
    `endIndex` - index, from zero, of the last item to be retrieved
    `sortConstraints` - zero or more constraints used to set the order of the returned values

### applyAdditionalConstraints

    protected void applyAdditionalConstraints(org.hibernate.Criteria crit)

  Invoked after the main criteria has been set up (firstResult, maxResults and any sort contraints). This gives subclasses a chance to apply additional constraints before the list of results is obtained from the criteria. This implementation does nothing and may be overridden.

### getRowValue

    public java.lang.Object getRowValue(int index)

  Returns a row value at the given index (which must be within the range defined by the call to `prepare(int, int, java.util.List)` ).

  Specified by:
    `getRowValue` in interface `GridDataSource`
  Parameters:
    `index` - of object
  Returns:
    object at that index

### getRowType

    public java.lang.Class getRowType()

  Returns the entity type, as provided via the constructor.

  Specified by:
    `getRowType` in interface `GridDataSource`
  Returns:
    the row type, or null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2012 The Apache Software Foundation.