Mybatis dynamic query
来源:互联网 发布:知乎联系方式 编辑:程序博客网 时间:2024/05/16 08:45
In my project, I ran into the issue that I have to use Sql In statement and the value in the in() is dynamic. With mybatis, we can create dynamic sql foreach.
Here is my case:
1. In the mapper class, I define my method:
@Component("twitterTweetMapper")public interface TweetMapper{public List<Tweet> getTweetsByOrganizationIds(List<Long> organizationIds);}
2. In the mapper.xml file, I define my sql statement.
<select id="getTweetsByOrganizationIds" resultType="org.twitter.model.Tweet">SELECT * FROM TWEETWHERE ORGANIZATIONID in<foreach item="item" index="index" collection="list" open="(" separator="," close=")">#{item}</foreach>ORDER BY TWEETCREATEDATE DESC LIMIT 3</select>
That's all. It's very easy, right?
For more dynamic queries, read the link:
http://loianegroner.com/2011/03/ibatis-mybatis-working-with-dynamic-queries-sql/
- Mybatis dynamic query
- Mybatis Dynamic Query 前言
- Mybatis Dynamic Query 框架整合
- Mybatis Dynamic Query 2.0 入门
- dynamic query on sql
- Liferay Dynamic Query API
- liferay Dynamic Query 查询
- Dynamic Query System 基本SBT
- Dynamic Linq Query 简单API
- Dynamic Query Adapter Epicor E10
- Dynamic Linq Query 简单API
- MyBatis dynamic sql demo!!!
- Mybatis Dynamic SQL
- Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library)
- [Liferay6.2]Liferay Dynamic Query API示例
- Dynamic Programming:303. Range Sum Query
- mybatis query 对象 or 查询
- Mybatis Query was empty错误
- IOC原理
- Struts2中访问Web元素的3中方法
- ios开发答疑录系列---(五)NSString 和NSCharacterset的不同之处
- ios开发答疑录系列---(四)OS开发中混合使用ARC和非ARC项目
- 网页设计中常用到的小技巧
- Mybatis dynamic query
- extjs分页和全局排序要注意的问题
- UIAccelerometer 加速计
- 从现在做起
- SSH中的Hibernate的DAO类转json时出错
- Intel WiDi & Miracast hdmi receiver dongle
- 新站 DBA and EBS DBA home
- 不知哪位仁兄有该软件,csdn好像不提供下载了哦
- hdu 4339 线段树