如何在 MyBatis 中使用带有注解的动态 SQL 查询(如何使用 selectProvider)? [英] How to use dynamic SQL query in MyBatis with annotation(how to use selectProvider)?

查看:44
本文介绍了如何在 MyBatis 中使用带有注解的动态 SQL 查询(如何使用 selectProvider)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图避免在 mybatis3 中使用额外的 xml 来定义映射器.注释恰到好处.

I am trying to avoid having an additional xml to define the mapper in mybatis3. Annotation fits right in.

我对@SelectProvider/@InsertProvider/etc 的用法有点困惑.不要以为网上有很多资源可以指导我完成此操作.

I am a bit confused by the usage of @SelectProvider/@InsertProvider/etc. Don't think there are many resources online guiding me through this.

基本上,我想在mybatis3中找到alternative for的注解版本.

Basically, I will like to find the annotation version of alternative for in mybatis3.

例如,我有一个 xml 映射器,我想将其转换为使用注释

For example, I have a xml mapper and I wanna convert it to use annotation

<select ...>
  <where>
    <if cause.....>
    </if>
    <if cause......>
    </if>
  </where>
</select>

谁能提供具体的答案/解决方案,包括代码?

Could anyone provide a concrete answer/solution including the code?

提前致谢!

推荐答案

另一种解决方案可能是:

An alternative solution for you could be:

在@annotation 的开头添加

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆