public interface UserMapper
{
@SelectProvider(type="UserSqlProvider.class" method="selectWithParam")
List<User> selectWithParam(Map<String,Object> param);
}
public classUserSqpProvider
{
public String selectWithParam(Map<String,Object> param)
{
return new SQL(){
{
SELECT("*")
FROM("User")
if(param.get("id") != null)
{
WHERE(" id=#{id}")
}
...
}.toString();
};
}
}
原文:http://www.cnblogs.com/tengfeixinxing/p/7075485.html