/** * Generic Manager that talks to GenericDao to CRUD POJOs. * * <p>Extend this interface if you want typesafe (no casting necessary) managers * for your domain objects. * * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a> * @param <T> a type variable * @param <PK> the primary key for that type */ public interface BaseService<T, PK extends Serializable> {
/** * Generic method used to get all objects of a particular type. This * is the same as lookup up all rows in a table. * @return List of populated objects */ List<T> getAll();
/** * Generic method to get an object based on class and identifier. An * ObjectRetrievalFailureException Runtime Exception is thrown if * nothing is found. * * @param id the identifier (primary key) of the object to get * @return a populated object * @see org.springframework.orm.ObjectRetrievalFailureException */ T get(PK id);
/** * Checks for existence of an object of type T using the id arg. * @param id the identifier (primary key) of the object to get * @return - true if it exists, false if it doesn't */ boolean exists(PK id);
/** * Generic method to save an object - handles both update and insert. * @param object the object to save * @return the updated object */ T save(T object);
/** * Generic method to delete an object based on class and id * @param id the identifier (primary key) of the object to remove */ void remove(PK id);
public void removes(PK[] ids);
void remove1(PK id);
public void removes1(PK[] ids); public List<T> getByHql(String hql,Object[] objs);
public List getAllByHql(String hql,Object[] objs);
public void updateQuery(final String hql,final Map map);
public List<T> getPageData(String hql, Map map, int pageIndex, int pageSize);
public List<T> getPageData(String hql, Map map);
public int getPageSize(String hql, Map map);
public BigDecimal getTotalCount(String hql, Map map);
public class BaseServiceImpl<T, PK extends Serializable> implements BaseService<T, PK> { /** * Log variable for all child classes. Uses LogFactory.getLog(getClass()) from Commons Logging */ protected final Log log = LogFactory.getLog(getClass());
/** * GenericDao instance, set by constructor of this class */ protected BaseDao<T, PK> baseDao;
/** * Public constructor for creating a new GenericManagerImpl. * @param genericDao the GenericDao to use for persistence */ public BaseServiceImpl(final BaseDao<T, PK> baseDao) { this.baseDao = baseDao; }