基于java8对tkmybatis语法加强

本文深入探讨了如何利用Java8的新特性对TkMybatis进行语法增强,包括Lambda表达式、Stream API等在数据操作中的应用,旨在提升代码的简洁性和效率。
摘要由CSDN通过智能技术生成
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

public interface Imapper<T> extends Mapper<T> {

	default List<T> selectByLambda(Tao... taos) {
		return selectByExample(make(taos));
	}

	default int selectCountByLambda(Tao... taos) {
		return selectCountByExample(make(taos));
	}

	default int deleteByLambda(Tao... taos) {
		return deleteByExample(make(taos));
	}

	default int seletCountByLambda(Tao... taos) {
		return deleteByExample(make(taos));
	}

	default int updateByLambda(T t, Tao... taos) {
		return updateByExample(t, make(taos));
	}

	default int updateSelectiveByLambda(T t, Tao... taos) {
		return updateByExampleSelective(t, make(taos));
	}

	default Example make(Tao... taos) {
		Example example = new Example(entityClass());
		for (Tao tao : taos)
			tao.accept(example.or());
		return example;
	}

	// 实际调用接口必须用default方法实现
	Class<?> entityClass();

}
import 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值