DAO和Service公共抽象接口实现
1、分页帮助类
?
?
?2、session获取方式
?
?4、基础service实现,针对webservice
?
@Transactionalpublic abstract class FrontBaseServiceImpl<Entity extends DominObject, PK extends Serializable, EntityDao extends BaseEntityDao<Entity, PK>>implements FrontBaseService<Entity, PK> {protected Logger log = Logger.getLogger(this.getClass());protected EntityDao entityDao;public EntityDao getEntityDao() {return entityDao;}/** * 子类进行注入 * * @param entityDao */public abstract void setEntityDao(EntityDao entityDao);@SuppressWarnings("unchecked")public PK save(Entity entity) {return (PK) this.entityDao.save(entity);}public void update(Entity entity) {this.entityDao.update(entity);}public void merge(Entity entity) {this.entityDao.merge(entity);}public void refresh(Entity entity) {this.entityDao.refresh(entity);}public void delete(PK id) {this.entityDao.delete(id);}@Transactional(readOnly = true)public Entity findById(PK id) {return this.entityDao.findById(id);}@Transactional(readOnly = true)public List<Entity> findByIds(Collection<PK> ids) {return this.entityDao.findByIds(ids);}@Transactional(readOnly = true)public List<Entity> getAll() {return this.entityDao.getAll();}@Transactional(readOnly = true)public Page<Entity> findAllByPage(Page<Entity> page) {return this.entityDao.findAllByPage(page);}public void delete(PK[] ids) {for (PK id : ids) {this.delete(id);}}public void saveOrUpdate(Entity entity){this.entityDao.saveOrUpdate(entity);}}