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.acegisecurity.domain.hibernate
Class DaoHibernate<E extends PersistableEntity>

    java.lang.Object
      org.springframework.dao.support.DaoSupport
          org.springframework.orm.hibernate3.support.HibernateDaoSupport
              org.acegisecurity.domain.hibernate.DaoHibernate<E>

All Implemented Interfaces:
  Dao<E>, EvictionCapable, InitializationCapable, InitializingBean

    public class DaoHibernate<E extends PersistableEntity>

extends HibernateDaoSupport
implements Dao<E>, EvictionCapable, InitializationCapable

Generics supporting `Dao` implementation that uses Hibernate 3 for persistence.

Version:
  $Id: DaoHibernate.java,v 1.11 2005/11/17 00:55:49 benalex Exp $
Author:
  Ben Alex, Matthew Porter

Field Summary

Fields inherited from class org.springframework.dao.support.DaoSupport
`logger`

Constructor Summary
`DaoHibernate()`

Method Summary
`E` | `create(E value)` Create a new object, with the current `PersistableEntity.getInternalId()` value being ignored.
`void` | `delete(E value)` Delete an object.
`protected HibernateTemplate` | `doGetHibernateTemplate()` Obtains a `HibernateTemplate` that uses the appropriate `Session` based on the value of `DetachmentContextHolder`.
`void` | `evict(PersistableEntity entity)` Removes the indicated persistent instance from the DAO's internal map/session.
`List<E>` | `findAll()` Return all persistent instances, including subclasses.
`List<E>` | `findId(Collection<Serializable> ids)` Find a `List` of `PersistableEntity`s, searched by their identifiers.
`Class` | `getSupportsClass()`
`ValidationManager` | `getValidationManager()`
`protected void` | `initDao()` Custom initialization behavior.
`protected void` | `initHibernateDao()` Allows subclasses to provide custom initialization behaviour.
`void` | `initialize(Object entity)` Initializes the indicated object.
`protected void` | `initializeAllZeroArgumentGetters(E entity)` Locates every `get*()` method against the passed entity and calls it.
`boolean` | `isInitialized(Object entity)` Indicaets whether the passed object is initialized or not.
`E` | `readId(Serializable id)` Load a persistent instance by its identifier, although some properties may be lazy loaded depending on the underlying DAO implementation and/or persistence engine mapping document.
`E` | `readPopulatedId(Serializable id)` Loads a persistent instance by its identifier, along with any lazy loaded properties associated with that instance.
`PaginatedList<E>` | `scroll(E value, int firstElement, int maxElements, String orderByAsc)` Find persistent instances with properties matching those of the passed `PersistableEntity`.
`PaginatedList<E>` | `scrollPopulated(E value, int firstElement, int maxElements, String orderByAsc)` Find persistent instances with properties matching those of the passed `PersistableEntity`, with a guarantee the returned results will have each of the `value` class' immediate properties initialized.
`PaginatedList<E>` | `scrollPopulatedWithSubclasses(E value, int firstElement, int maxElements, String orderByAsc)` Find persistent instances with properties matching those of the passed `PersistableEntity`, ignoring the class of the passed `PersistableEntity` (useful if you pass a superclass, as you want to find all subclass instances which match).
`PaginatedList<E>` | `scrollWithSubclasses(E value, int firstElement, int maxElements, String orderByAsc)` Find persistent instances with properties matching those of the passed `PersistableEntity`, ignoring the class of the passed `PersistableEntity` (useful if you pass a superclass, as you want to find all subclass instances which match).
`void` | `setSupportsClass(Class supportClass)`
`void` | `setValidationManager(ValidationManager validationManager)`
`boolean` | `supports(Class clazz)` Indicates whether the DAO instance provides persistence services for the specified class.
`E` | `update(E value)` Update an object.
`protected void` | `validate(E value)`

Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
`checkDaoConfig, closeSessionIfNecessary, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory`

Methods inherited from class org.springframework.dao.support.DaoSupport
`afterPropertiesSet`

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

Constructor Detail

### DaoHibernate

    public DaoHibernate()

Method Detail

### doGetHibernateTemplate

    protected HibernateTemplate doGetHibernateTemplate()

  Obtains a `HibernateTemplate` that uses the appropriate `Session` based on the value of `DetachmentContextHolder`.

  Specifically, if `DetachmentContextHolder` requires detached instances, the method will build a new `Session` (ignore the current thread-bound `Session`) and use that new `Session` in the `HibernateTemplate`. If `DetachmentContextHolder` is at its fault `false` value, the returned `HibernateTemplate` will simply use the `Session` obtained from the superclass, which is generally the same `Session` as used for the transaction.

  Returns:
    the template, containing the correct `Session` based on the `DetachmentContactHolder` request

### setSupportsClass

    public void setSupportsClass(Class supportClass)

### getSupportsClass

    public Class getSupportsClass()

### getValidationManager

    public ValidationManager getValidationManager()

### setValidationManager

    public void setValidationManager(ValidationManager validationManager)

### create

    public E create(E value)

  Description copied from interface: `Dao`
  Create a new object, with the current `PersistableEntity.getInternalId()` value being ignored.

  Specified by:
    `create` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - (without the identity property initialized)
  Returns:
    the value created (with the identity property initialised)

### validate

    protected void validate(E value)
                     throws DataIntegrityViolationException

  Throws:
    `DataIntegrityViolationException`

### delete

    public void delete(E value)

  Description copied from interface: `Dao`
  Delete an object.

  Specified by:
    `delete` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - the value to delete

### evict

    public void evict(PersistableEntity entity)

  Description copied from interface: `EvictionCapable`
  Removes the indicated persistent instance from the DAO's internal map/session.

  If the passed object does not exist in the internal map/session, the invocation has no effect.

  May throw an exception if the implementation so desires.

  Specified by:
    `evict` in interface `EvictionCapable`
  Parameters:
    `entity` - to remove from the internal map/session

### findAll

    public List<E> findAll()

  Description copied from interface: `Dao`
  Return all persistent instances, including subclasses.

  Specified by:
    `findAll` in interface `Dao<E extends PersistableEntity>`
  Returns:
    all persistence instances (an empty `List` will be returned if no matches are found)

### findId

    public List<E> findId(Collection<Serializable> ids)

  Description copied from interface: `Dao`
  Find a `List` of `PersistableEntity`s, searched by their identifiers.

  Specified by:
    `findId` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `ids` - collection of identifiers to locate
  Returns:
    the values with those identifiers (an empty `List` will be returned if no matches are found)

### readId

    public E readId(Serializable id)

  Description copied from interface: `Dao`
  Load a persistent instance by its identifier, although some properties may be lazy loaded depending on the underlying DAO implementation and/or persistence engine mapping document.

  Specified by:
    `readId` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `id` - the identifier of the persistent instance desired to be retrieved
  Returns:
    the request item, or `null` if not found

### readPopulatedId

    public E readPopulatedId(Serializable id)

  Description copied from interface: `Dao`
  Loads a persistent instance by its identifier, along with any lazy loaded properties associated with that instance.

  Specified by:
    `readPopulatedId` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `id` - the identifier of the persistent instance desired to be retrieved
  Returns:
    the request item, or `null` if not found

### initializeAllZeroArgumentGetters

    protected void initializeAllZeroArgumentGetters(E entity)

  Locates every `get*()` method against the passed entity and calls it. This method does not nest its initialization beyond the immediately passed entity.

  For example, a Foo object might provide a getBar() method. Passing the Foo instance to this method will guarantee getBar() is available to the services layer. However, if getBar() returned a Bar which in turn provided a getCar() method, there is NO GUARANTEE the getCar() method will be initialized.

  Parameters:
    `entity` - for which its immediate getters should be initialized

### scroll

    public PaginatedList<E> scroll(E value,
                                   int firstElement,
                                   int maxElements,
                                   String orderByAsc)

  Description copied from interface: `Dao`
  Find persistent instances with properties matching those of the passed `PersistableEntity`.

  Persistent instances are matched on the basis of query by example. Properties whose value is `null`, empty `String`s, and any `Collection`s are ignored in the query by example evaluation.

  Specified by:
    `scroll` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - parameters to filter on (the class of this object will be added to the filter)
    `firstElement` - the first result (start at zero to obtain all results)
    `maxElements` - the maximum number of results desired for this page of the result set
    `orderByAsc` - the property name of the `PersistableEntity` that should be used to order the results
  Returns:
    the requested page of the result list (a properly formed `PaginatedList` is returned if no results match)

### scrollWithSubclasses

    public PaginatedList<E> scrollWithSubclasses(E value,
                                                 int firstElement,
                                                 int maxElements,
                                                 String orderByAsc)

  Description copied from interface: `Dao`
  Find persistent instances with properties matching those of the passed `PersistableEntity`, ignoring the class of the passed `PersistableEntity` (useful if you pass a superclass, as you want to find all subclass instances which match).

  Specified by:
    `scrollWithSubclasses` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - parameters to filter on (the class of this object will NOT be added to the filter)
    `firstElement` - the first result (start at zero to obtain all results)
    `maxElements` - the maximum number of results desired for this page of the result set
    `orderByAsc` - the property name of the `PersistableEntity` that should be used to order the results
  Returns:
    the requested page of the result list (a properly formed `PaginatedList` is returned if no results match)

### scrollPopulated

    public PaginatedList<E> scrollPopulated(E value,
                                            int firstElement,
                                            int maxElements,
                                            String orderByAsc)

  Description copied from interface: `Dao`
  Find persistent instances with properties matching those of the passed `PersistableEntity`, with a guarantee the returned results will have each of the `value` class' immediate properties initialized.

  Persistent instances are matched on the basis of query by example. Properties whose value is `null`, empty `String`s, and any `Collection`s are ignored in the query by example evaluation.

  Specified by:
    `scrollPopulated` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - parameters to filter on (the class of this object will be added to the filter)
    `firstElement` - the first result (start at zero to obtain all results)
    `maxElements` - the maximum number of results desired for this page of the result set
    `orderByAsc` - the property name of the `PersistableEntity` that should be used to order the results
  Returns:
    the requested page of the result list (a properly formed `PaginatedList` is returned if no results match)

### scrollPopulatedWithSubclasses

    public PaginatedList<E> scrollPopulatedWithSubclasses(E value,
                                                          int firstElement,
                                                          int maxElements,
                                                          String orderByAsc)

  Description copied from interface: `Dao`
  Find persistent instances with properties matching those of the passed `PersistableEntity`, ignoring the class of the passed `PersistableEntity` (useful if you pass a superclass, as you want to find all subclass instances which match). Guarantees the returned results will have each of the DAO's `supports` class' immediate properties initialized.

  Specified by:
    `scrollPopulatedWithSubclasses` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - parameters to filter on (the class of this object will NOT be added to the filter)
    `firstElement` - the first result (start at zero to obtain all results)
    `maxElements` - the maximum number of results desired for this page of the result set
    `orderByAsc` - the property name of the `PersistableEntity` that should be used to order the results
  Returns:
    the requested page of the result list (a properly formed `PaginatedList` is returned if no results match)

### supports

    public boolean supports(Class clazz)

  Description copied from interface: `Dao`
  Indicates whether the DAO instance provides persistence services for the specified class.

  Specified by:
    `supports` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `clazz` - to test, which should be an implementation of `PersistableEntity`
  Returns:
    `true` or `false`, indicating whether or not the passed class is supported by this DAO instance

### update

    public E update(E value)

  Description copied from interface: `Dao`
  Update an object.

  Specified by:
    `update` in interface `Dao<E extends PersistableEntity>`
  Parameters:
    `value` - to update, with the `PersistableEntity` having a non-`null` identifier
  Returns:
    the updated value

### initDao

    protected final void initDao()
                          throws Exception

  Custom initialization behavior. Called by superclass.

  Overrides:
    `initDao` in class `DaoSupport`
  Throws:
    `Exception` - if initialization fails

### initHibernateDao

    protected void initHibernateDao()
                             throws Exception

  Allows subclasses to provide custom initialization behaviour. Called during `initDao()`.

  Throws:
    `Exception`

### initialize

    public void initialize(Object entity)

  Description copied from interface: `InitializationCapable`
  Initializes the indicated object.

  May throw an exception if the implementation so desires.

  Specified by:
    `initialize` in interface `InitializationCapable`
  Parameters:
    `entity` - to initialize

### isInitialized

    public boolean isInitialized(Object entity)

  Description copied from interface: `InitializationCapable`
  Indicaets whether the passed object is initialized or not.

  Specified by:
    `isInitialized` in interface `InitializationCapable`
  Parameters:
    `entity` - to determine if initialized
  Returns:
    `true` if initialized, `false` is uninitialized or the initialization status is unknown

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 © 2004-2005 Acegi Technology Pty Limited. All Rights Reserved.