bboss持久层公共sql片段定义和引用方法说明
在配置sql语句时,经常会碰到多条sql语句里面使用同样的sql条件或者sql片段的情况,为了便于维护和提高配置的简洁性,一般会将这些公共部分剥离出来,配置成独立的sql片段,然后在所有需要的地方引入即可。下面介绍在bboss持久层框架里面如何定义和引用公共sql片段。
首先在项目中导入bboss 持久层包:
maven坐标
<dependency>
<groupId>com.bbossgroups</groupId>
<artifactId>bboss-persistent</artifactId>
<version>5.0.7.5</version>
</dependency>
gradle坐标
compile 'com.bbossgroups:bboss-persistent:5.0.7.5'
直接看实例:
定义公共sql片段:queryOrgmanagerRoleIDs
<property name="queryOrgmanagerRoleIDs">
<![CDATA[
select role_id from td_sm_role where role_name in ('orgmanager','orgmanagerroletemplate')
]]>
</property>
通过@{}语法引用公共sql片段:queryOrgmanagerRoleIDs
<property name="removeUserRoles">
<![CDATA[
delete from td_sm_userrole where user_id = ? and role_id not in (@{queryOrgmanagerRoleIDs})
]]>
</property>
<property name="removeGroupRoles">
<![CDATA[
delete from td_sm_grouprole where group_id = ? and role_id not in (@{queryOrgmanagerRoleIDs})
]]>
</property>
@{queryOrgmanagerRoleIDs}是sql片段引用语法,其中
片段sql queryOrgmanagerRoleIDs一定要在引用这个片段的sql之前定义,queryOrgmanagerRoleIDs对应的sql片段也可以定义在外部属性文件中。
@{queryOrgmanagerRoleIDs}sql片段引用语法一定要和其他的sql绑定变量区分开来:
#[varname] 这个是sql绑定变量语法
$varname 这个是sql语句值替换变量语法
${varname} 这个是非sql配置ioc文件引用外部属性变量的语法 参考文档:
http://yin-bp.iteye.com/blog/2325602
相关文档:
http://yin-bp.iteye.com/blog/1112887
分享到:
相关推荐
资源目录: 项目源码(eshelloword.rar) bboss elasticsearch开发入门教程.wmv 搭建bboss elasticsearch开发环境.wmv 说明.txt
bboss会话共享培训文档,学习bboss不可多得的资料,值得拥有。
bboss es特点请访问: https://www.oschina.net/p/bboss-elastic
企业级 J2EE 开源框架:bboss
bboss+es基本操作示例,elasticsearch,bboss,java使用demo
bboss功能涵盖ioc,mvc,jsp自定义标签库,持久层,全局事务托管,安全认证,SSO,web会话共享,cxfwebservice服务发布和管理,hessian服务发布和管理等功能。另外还提供了符合中国式自由流的bboss activiti工作流...
NULL 博文链接:https://yin-bp.iteye.com/blog/926166
springboot集成ElasticsearchBboss调用Elasticsearch的案例分享
官方版本,亲测可用
bboss-datatran 由 bboss 开源的数据采集&流批一体化工具,提供数据采集、数据清洗转换处理和数据入库以及数据指标统计计算流批一体化处理功能。
Elasticsearch rest client bboss介绍-Elastic2018中国开发者大会演讲稿
NULL 博文链接:https://yin-bp.iteye.com/blog/2174863
NULL 博文链接:https://yin-bp.iteye.com/blog/2177475
浙江移动BBOSS系统快速入门手册V0.1归类.pdf
基于java语言比mybatis更实用的orm框架,支持mysql、oracle、postgresql、sqlserver、db2、dm、mongodb
NULL 博文链接:https://yin-bp.iteye.com/blog/1131637
NULL 博文链接:https://yin-bp.iteye.com/blog/1449900
基于bboss新版平台项目环境搭建和代码工具使用视频教程
官方版本,亲测可用
Bboss国际化实践.ppt