|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.appfuse.service.impl.GenericManagerImpl<T,PK>
T - a type variablePK - the primary key for that typepublic class GenericManagerImpl<T,PK extends Serializable>
This class serves as the Base class for all other Managers - namely to hold common CRUD methods that they might all use. You should only need to extend this class when your require custom CRUD logic.
To register this class in your Spring context file, use the following XML.
<bean id="userManager" class="org.appfuse.service.impl.GenericManagerImpl">
<constructor-arg>
<bean class="org.appfuse.dao.hibernate.GenericDaoHibernate">
<constructor-arg value="org.appfuse.model.User"/>
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
</constructor-arg>
</bean>
If you're using iBATIS instead of Hibernate, use:
<bean id="userManager" class="org.appfuse.service.impl.GenericManagerImpl">
<constructor-arg>
<bean class="org.appfuse.dao.ibatis.GenericDaoiBatis">
<constructor-arg value="org.appfuse.model.User"/>
<property name="dataSource" ref="dataSource"/>
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
</constructor-arg>
</bean>
| Field Summary | |
|---|---|
protected GenericDao<T,PK> |
dao
GenericDao instance, set by constructor of child classes |
protected org.apache.commons.logging.Log |
log
Log variable for all child classes. |
| Constructor Summary | |
|---|---|
GenericManagerImpl()
|
|
GenericManagerImpl(GenericDao<T,PK> genericDao)
|
|
| Method Summary | |
|---|---|
boolean |
exists(PK id)
Checks for existence of an object of type T using the id arg. |
T |
get(PK id)
Generic method to get an object based on class and identifier. |
List<T> |
getAll()
Generic method used to get all objects of a particular type. |
void |
reindex()
Generic method to regenerate full text index of the persistent class T |
void |
reindexAll(boolean async)
Generic method to regenerate full text index of all indexed classes |
void |
remove(PK id)
Generic method to delete an object based on class and id |
void |
remove(T object)
Generic method to delete an object |
T |
save(T object)
Generic method to save an object - handles both update and insert. |
List<T> |
search(String q,
Class clazz)
Generic method to search for an object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final org.apache.commons.logging.Log log
protected GenericDao<T,PK extends Serializable> dao
| Constructor Detail |
|---|
public GenericManagerImpl()
public GenericManagerImpl(GenericDao<T,PK> genericDao)
| Method Detail |
|---|
public List<T> getAll()
getAll in interface GenericManager<T,PK extends Serializable>public T get(PK id)
get in interface GenericManager<T,PK extends Serializable>id - the identifier (primary key) of the object to get
ObjectRetrievalFailureExceptionpublic boolean exists(PK id)
exists in interface GenericManager<T,PK extends Serializable>id - the identifier (primary key) of the object to get
public T save(T object)
save in interface GenericManager<T,PK extends Serializable>object - the object to save
public void remove(T object)
remove in interface GenericManager<T,PK extends Serializable>object - the object to removepublic void remove(PK id)
remove in interface GenericManager<T,PK extends Serializable>id - the identifier (primary key) of the object to remove
public List<T> search(String q,
Class clazz)
search in interface GenericManager<T,PK extends Serializable>q - the search termclazz - type of class to search for.
public void reindex()
reindex in interface GenericManager<T,PK extends Serializable>public void reindexAll(boolean async)
reindexAll in interface GenericManager<T,PK extends Serializable>async - true to perform the reindexing asynchronously
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||