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

## com.gisgraphy.service.impl
Class GenericManagerImpl<T,PK extends java.io.Serializable>

    java.lang.Object
      com.gisgraphy.service.impl.GenericManagerImpl<T,PK>

Type Parameters:
  `T` - a type variable
  `PK` - the primary key for that type

All Implemented Interfaces:
  GenericManager<T,PK>

    public class GenericManagerImpl<T,PK extends java.io.Serializable>

extends java.lang.Object
implements GenericManager<T,PK>

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="com.gisgraphy.service.impl.GenericManagerImpl">
             <constructor-arg>
                 <bean class="com.gisgraphy.dao.hibernate.GenericDaoHibernate">
                     <constructor-arg value="com.gisgraphy.model.User"/>
                     <property name="sessionFactory" ref="sessionFactory"/>
                 </bean>
             </constructor-arg>
         </bean>

If you're using iBATIS instead of Hibernate, use:

         <bean id="userManager" class="com.gisgraphy.service.impl.GenericManagerImpl">
             <constructor-arg>
                 <bean class="com.gisgraphy.dao.ibatis.GenericDaoiBatis">
                     <constructor-arg value="com.gisgraphy.model.User"/>
                     <property name="dataSource" ref="dataSource"/>
                     <property name="sqlMapClient" ref="sqlMapClient"/>
                 </bean>
             </constructor-arg>
         </bean>

Author:
  Matt Raible

Field Summary
`protected GenericDao<T,PK>` | `genericDao` GenericDao instance, set by constructor of this class
`protected org.apache.commons.logging.Log` | `log` Log variable for all child classes.

Constructor Summary
`GenericManagerImpl(GenericDao<T,PK> genericDao)` Public constructor for creating a new GenericManagerImpl.

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.
`java.util.List<T>` | `getAll()` Generic method used to get all objects of a particular type.
`void` | `remove(PK id)` Generic method to delete an object based on class and id
`T` | `save(T object)` Generic method to save an object - handles both update and insert.

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

Field Detail

### log

    protected final org.apache.commons.logging.Log log

  Log variable for all child classes. Uses LogFactory.getLog(getClass()) from Commons Logging

### genericDao

    protected GenericDao<T,PK extends java.io.Serializable> genericDao

  GenericDao instance, set by constructor of this class

Constructor Detail

### GenericManagerImpl

    public GenericManagerImpl(GenericDao<T,PK> genericDao)

  Public constructor for creating a new GenericManagerImpl.

  Parameters:
    `genericDao` - the GenericDao to use for persistence

Method Detail

### getAll

    public java.util.List<T> getAll()

  Generic method used to get all objects of a particular type. This is the same as lookup up all rows in a table.

  Specified by:
    `getAll` in interface `GenericManager<T,PK extends java.io.Serializable>`
  Returns:
    List of populated objects

### get

    public T get(PK id)

  Generic method to get an object based on class and identifier. An ObjectRetrievalFailureException Runtime Exception is thrown if nothing is found.

  Specified by:
    `get` in interface `GenericManager<T,PK extends java.io.Serializable>`
  Parameters:
    `id` - the identifier (primary key) of the object to get
  Returns:
    a populated object
  See Also:
    `ObjectRetrievalFailureException`

### exists

    public boolean exists(PK id)

  Checks for existence of an object of type T using the id arg.

  Specified by:
    `exists` in interface `GenericManager<T,PK extends java.io.Serializable>`
  Parameters:
    `id` - the identifier (primary key) of the object to get
  Returns:
    - true if it exists, false if it doesn't

### save

    public T save(T object)

  Generic method to save an object - handles both update and insert.

  Specified by:
    `save` in interface `GenericManager<T,PK extends java.io.Serializable>`
  Parameters:
    `object` - the object to save
  Returns:
    the updated object

### remove

    public void remove(PK id)

  Generic method to delete an object based on class and id

  Specified by:
    `remove` in interface `GenericManager<T,PK extends java.io.Serializable>`
  Parameters:
    `id` - the identifier (primary key) of the object to remove

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 © 2009. All Rights Reserved.