|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate3.support.HibernateDaoSupport
org.acegisecurity.domain.hibernate.DaoHibernate<E>
public class DaoHibernate<E extends PersistableEntity>
Generics supporting Dao implementation that uses Hibernate 3 for persistence.
| 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 PersistableEntitys, 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 |
|---|
public DaoHibernate()
| Method Detail |
|---|
protected HibernateTemplate doGetHibernateTemplate()
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.
Session based on the
DetachmentContactHolder requestpublic void setSupportsClass(Class supportClass)
public Class getSupportsClass()
public ValidationManager getValidationManager()
public void setValidationManager(ValidationManager validationManager)
public E create(E value)
DaoPersistableEntity.getInternalId() value being ignored.
create in interface Dao<E extends PersistableEntity>value - (without the identity property initialized)
protected void validate(E value)
throws DataIntegrityViolationException
DataIntegrityViolationExceptionpublic void delete(E value)
Dao
delete in interface Dao<E extends PersistableEntity>value - the value to deletepublic void evict(PersistableEntity entity)
EvictionCapableIf 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.
evict in interface EvictionCapableentity - to remove from the internal map/sessionpublic List<E> findAll()
Dao
findAll in interface Dao<E extends PersistableEntity>List will be
returned if no matches are found)public List<E> findId(Collection<Serializable> ids)
DaoList of PersistableEntitys, searched by
their identifiers.
findId in interface Dao<E extends PersistableEntity>ids - collection of identifiers to locate
List
will be returned if no matches are found)public E readId(Serializable id)
Dao
readId in interface Dao<E extends PersistableEntity>id - the identifier of the persistent instance desired to be
retrieved
null if not foundpublic E readPopulatedId(Serializable id)
Dao
readPopulatedId in interface Dao<E extends PersistableEntity>id - the identifier of the persistent instance desired to be
retrieved
null if not foundprotected void initializeAllZeroArgumentGetters(E entity)
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.
entity - for which its immediate getters should be initialized
public PaginatedList<E> scroll(E value,
int firstElement,
int maxElements,
String orderByAsc)
DaoPersistableEntity.
Persistent instances are matched on the basis of query by example.
Properties whose value is null, empty
Strings, and any Collections are ignored in
the query by example evaluation.
scroll in interface Dao<E extends PersistableEntity>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 setorderByAsc - the property name of the
PersistableEntity that should be used to order the
results
PaginatedList is returned if no results match)
public PaginatedList<E> scrollWithSubclasses(E value,
int firstElement,
int maxElements,
String orderByAsc)
DaoPersistableEntity, ignoring the class of the passed
PersistableEntity (useful if you pass a superclass, as you
want to find all subclass instances which match).
scrollWithSubclasses in interface Dao<E extends PersistableEntity>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 setorderByAsc - the property name of the
PersistableEntity that should be used to order the
results
PaginatedList is returned if no results match)
public PaginatedList<E> scrollPopulated(E value,
int firstElement,
int maxElements,
String orderByAsc)
DaoPersistableEntity, 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
Strings, and any Collections are ignored in
the query by example evaluation.
scrollPopulated in interface Dao<E extends PersistableEntity>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 setorderByAsc - the property name of the
PersistableEntity that should be used to order the
results
PaginatedList is returned if no results match)
public PaginatedList<E> scrollPopulatedWithSubclasses(E value,
int firstElement,
int maxElements,
String orderByAsc)
DaoPersistableEntity, 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.
scrollPopulatedWithSubclasses in interface Dao<E extends PersistableEntity>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 setorderByAsc - the property name of the
PersistableEntity that should be used to order the
results
PaginatedList is returned if no results match)public boolean supports(Class clazz)
Dao
supports in interface Dao<E extends PersistableEntity>clazz - to test, which should be an implementation of
PersistableEntity
true or false, indicating whether or
not the passed class is supported by this DAO instancepublic E update(E value)
Dao
update in interface Dao<E extends PersistableEntity>value - to update, with the PersistableEntity having a
non-null identifier
protected final void initDao()
throws Exception
initDao in class DaoSupportException - if initialization fails
protected void initHibernateDao()
throws Exception
initDao().
Exceptionpublic void initialize(Object entity)
InitializationCapableMay throw an exception if the implementation so desires.
initialize in interface InitializationCapableentity - to initializepublic boolean isInitialized(Object entity)
InitializationCapable
isInitialized in interface InitializationCapableentity - to determine if initialized
true if initialized, false is uninitialized or
the initialization status is unknown
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||