mybatis 中 使用basebao和接口两种形式那种好?

吃不饱 发布于 2016/06/02 11:39
阅读 632
收藏 1

公司的mybatis 是使用的basedao+xml的方式实现调用的

@Repository("baseDao")
public class BaseDaoImpl implements BaseDao{
	@Autowired
	private SqlSessionTemplate template;

	@Override
	public <T> T selectOne(String statement, Object parameter) {
		return template.selectOne(statement, parameter);
	}

	@Override
	public <T> List<T> selectList(String statement, Object parameter) {
		return template.selectList(statement, parameter);
	}

	@Override
	public <T> List<T> selectList(String statement) {
		return template.selectList(statement);
	}

	@Override
	public <T> int insert(String statement, Object parameter) {
		return 	template.insert(statement, parameter);
	}

	@Override
	public <T> int update(String statement, Object parameter) {
		
		return template.update(statement, parameter);
	}

	@Override
	public <T> int delete(String statement, Object parameter) {
		return template.delete(statement, parameter);
	}

}


实现

@Service("logService")
public class LogServiceImpl implements LogService{
	@Autowired
	private BaseDao baseDao;

	@Override
	public int createSystemLog(Log log) {
									
		return this.baseDao.insert("com.zefu.portal.log.LogDao.insert", log);
	}

	@Override
	public int deleteSystemLog(Log log) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, Object>findListByPage(Log log, Page page) {	
		Map<String, Object> map=new HashMap<String, Object>();
	    //log.setPage(page);
		map.put("log", log);
		map.put("page", page);
		List<Log> list=this.baseDao.selectList("com.zefu.portal.log.LogDao.findListByPage", map);
		map.put("data", list);
		//map.put("page", page);
		return map;
	}

	@Override
	public Log get(Log log) {
		return this.baseDao.selectOne("com.zefu.portal.log.LogDao.get",log);

	}

}



而我之前搭建的是使用接口+xml的形式 
/**
 * <p>Title: 短信相关-短信下发表-sms_push_crm</p>
 * <p>Description: 短信相关-短信下发表-sms_push_crm</p>
 * @author zhagnslc
 */
public interface SmsPushCrmMapper {

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sms_push_crm
     *
     * @mbggenerated Sat Jun 20 14:07:32 CST 2015
     */
    int insert(SmsPushCrm record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table sms_push_crm
     *
     * @mbggenerated Sat Jun 20 14:07:32 CST 2015
     */
    int insertSelective(SmsPushCrm record);

    
}


请问那种方式好 为什么?


加载中
0
LucEsape
LucEsape
接口+mapper.xml
吃不饱
吃不饱
为什么呢
0
返回顶部
顶部