net.databinder.models.hib
Class HibernateProvider

java.lang.Object
  extended by org.apache.wicket.markup.repeater.data.DefaultDataProvider
      extended by net.databinder.models.PropertyDataProvider
          extended by net.databinder.models.hib.HibernateProvider
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.IClusterable, org.apache.wicket.markup.repeater.data.IDataProvider, org.apache.wicket.model.IDetachable
Direct Known Subclasses:
SortableHibernateProvider

public class HibernateProvider
extends PropertyDataProvider

Provides query results to DataView and related components. Like the Hibernate model classes, the results of this provider can be altered by query binders and criteria builders. By default this provider wraps items in a compound property model in addition to a Hibernate model. This is convenient for mapping DataView subcomponents as bean properties (as with PropertyListView). However, DataTable will not work with a compound property model. Call setWrapWithPropertyModel(false) when using with DataTable, DataGridView, or any other time you do not want a compound property model.

Author:
Nathan Hamblen
See Also:
Serialized Form

Constructor Summary
HibernateProvider(java.lang.Class objectClass)
          Provides all entities of the given class.
HibernateProvider(java.lang.Class objectClass, CriteriaBuilder criteriaBuilder)
          Provides entities of the given class meeting the supplied criteria.
HibernateProvider(java.lang.Class objectClass, CriteriaBuilder criteriaBuilder, CriteriaBuilder criteriaOrderer)
          Provides all entities of the given class using a distinct criteria builder for the order query.
HibernateProvider(java.lang.Class objectClass, OrderingCriteriaBuilder criteriaBuider)
          Provides all entities of the given class.
HibernateProvider(QueryBuilder queryBuilder, QueryBuilder countQueryBuilder)
           
HibernateProvider(java.lang.String query)
          Provides entities matching the given query.
HibernateProvider(java.lang.String query, QueryBinder queryBinder)
          Provides entities matching the given query with bound parameters.
HibernateProvider(java.lang.String query, QueryBinder queryBinder, java.lang.String countQuery, QueryBinder countQueryBinder)
          Provides entities matching the given queries with bound parameters.
HibernateProvider(java.lang.String query, java.lang.String countQuery)
          Provides entities matching the given queries.
 
Method Summary
protected  org.apache.wicket.model.IModel dataModel(java.lang.Object object)
          Wrap in appropriate persistent model in subclass
 void detach()
          does nothing
 java.lang.Object getFactoryKey()
           
 java.util.Iterator iterator(int first, int count)
          It should not normally be necessary to override (or call) this default implementation.
protected static java.lang.String makeCount(java.lang.String query)
           
 HibernateProvider setFactoryKey(java.lang.Object key)
          Set a factory key other than the default (null).
 int size()
          Only override this method if a single count query or criteria projection is not possible.
 
Methods inherited from class net.databinder.models.PropertyDataProvider
model, setWrapWithPropertyModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateProvider

public HibernateProvider(java.lang.Class objectClass)
Provides all entities of the given class.


HibernateProvider

public HibernateProvider(java.lang.Class objectClass,
                         CriteriaBuilder criteriaBuilder,
                         CriteriaBuilder criteriaOrderer)
Provides all entities of the given class using a distinct criteria builder for the order query.

Parameters:
objectClass -
criteriaBuilder - base criteria builder
criteriaOrderer - add ordering information ONLY, base criteria will be called first

HibernateProvider

public HibernateProvider(java.lang.Class objectClass,
                         OrderingCriteriaBuilder criteriaBuider)
Provides all entities of the given class.

Parameters:
objectClass -
criteriaBuider - builds different criteria objects for iterator() and size()

HibernateProvider

public HibernateProvider(java.lang.Class objectClass,
                         CriteriaBuilder criteriaBuilder)
Provides entities of the given class meeting the supplied criteria.


HibernateProvider

public HibernateProvider(java.lang.String query)
Provides entities matching the given query. The count query is derived by prefixing "select count(*)" to the given query; this will fail if the supplied query has a select clause.


HibernateProvider

public HibernateProvider(java.lang.String query,
                         java.lang.String countQuery)
Provides entities matching the given queries.


HibernateProvider

public HibernateProvider(java.lang.String query,
                         QueryBinder queryBinder)
Provides entities matching the given query with bound parameters. The count query is derived by prefixing "select count(*)" to the given query; this will fail if the supplied query has a select clause.


HibernateProvider

public HibernateProvider(java.lang.String query,
                         QueryBinder queryBinder,
                         java.lang.String countQuery,
                         QueryBinder countQueryBinder)
Provides entities matching the given queries with bound parameters.

Parameters:
query - query to return entities
queryBinder - binder for the standard query
countQuery - query to return count of entities
countQueryBinder - binder for the count query (may be same as queryBinder)

HibernateProvider

public HibernateProvider(QueryBuilder queryBuilder,
                         QueryBuilder countQueryBuilder)
Method Detail

makeCount

protected static java.lang.String makeCount(java.lang.String query)
Returns:
query with select count(*) prepended

getFactoryKey

public java.lang.Object getFactoryKey()
Returns:
session factory key, or null for the default factory

setFactoryKey

public HibernateProvider setFactoryKey(java.lang.Object key)
Set a factory key other than the default (null).

Parameters:
key - session factory key
Returns:
this, for chaining

iterator

public java.util.Iterator iterator(int first,
                                   int count)
It should not normally be necessary to override (or call) this default implementation.


size

public int size()
Only override this method if a single count query or criteria projection is not possible.


dataModel

protected org.apache.wicket.model.IModel dataModel(java.lang.Object object)
Description copied from class: PropertyDataProvider
Wrap in appropriate persistent model in subclass

Specified by:
dataModel in class PropertyDataProvider

detach

public void detach()
does nothing

Specified by:
detach in interface org.apache.wicket.model.IDetachable
Overrides:
detach in class org.apache.wicket.markup.repeater.data.DefaultDataProvider


Copyright © 2005-2008 Nathan Hamblen. All Rights Reserved.