mybatis如何实现这样的联合SQL

tongkuang 2013-10-15 11:03:23
想实现在这样的一条SQL请问mybatis怎么写?
select * from xx
where (name='x1' or info='x2') and pt='x3'

//代码片段
....
FunctionLinkExample example = new FunctionLinkExample();
FunctionLinkExample.Criteria example1 = example.createCriteria();
FunctionLinkExample.Criteria example2 = example.createCriteria();
if(StringUtils.isNotEmpty(functionLink.getName())){
example.or(example1.andNameLike("%" + functionLink.getName() + "%"));
example.or(example1.andInfoLike("%" + functionLink.getName() + "%"));
}
example2.andFlatformEqualTo(functionLink.getFlatform());
example.or(example2);
return this.functionLinkMapper.countByExample(example);
.....

这样写不行,请问哪里错了?
...全文
950 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
萝asdf 2013-10-21
  • 打赏
  • 举报
回复
引用 1 楼 java2000_net 的回复:
直接传个String不行吗?太费劲了。
又看到老紫竹大哥了,想当初我还是菜菜的时候,老紫竹大哥已经是大牛了,如今感慨良多,唉。
无聊找乐 2013-10-17
  • 打赏
  • 举报
回复
写在xml里直接用
失落夏天 2013-10-17
  • 打赏
  • 举报
回复
都是写在xml中直接用的。。
老紫竹 2013-10-17
  • 打赏
  • 举报
回复
直接传个String不行吗?太费劲了。
tongkuang 2013-10-17
  • 打赏
  • 举报
回复
但跟整体框架就有点格格不入了
tongkuang 2013-10-17
  • 打赏
  • 举报
回复
引用 1 楼 java2000_net 的回复:
直接传个String不行吗?太费劲了。
这个思路很有见解~~~

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧