bboss persistence layer public sql fragment definition and reference method description

Definition and reference method of common sql fragments in bboss persistence layer

When configuring sql statements, it is often encountered that the same sql conditions or sql fragments are used in multiple sql statements. In order to facilitate maintenance and improve the simplicity of configuration, generally These common parts are stripped out, configured into independent SQL fragments, and then imported wherever needed. The following describes how to define and reference common SQL fragments in the bboss persistence layer framework.
First import the bboss persistence layer package in the project:
maven coordinates
<dependency>
    <groupId>com.bbossgroups</groupId>
    <artifactId>bboss-persistent</artifactId>
    <version>5.0.3.5</version>
</dependency>
gradle Coordinate
compile 'com.bbossgroups:bboss-persistent:5.0.3.5'

to see the example directly:

Define common sql fragment: queryOrgmanagerRoleIDs
<property name="queryOrgmanagerRoleIDs">
		<![CDATA[
			select role_id from td_sm_role where role_name in ('orgmanager','orgmanagerroletemplate')
		]]>
	</property>
Referencing public sql fragments via @{} syntax: 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} is the SQL fragment reference syntax, where the fragment sql queryOrgmanagerRoleIDs must be defined before the SQL that references this fragment , and the SQL fragment corresponding to queryOrgmanagerRoleIDs can also be defined in an external property file.

@{queryOrgmanagerRoleIDs} The SQL fragment reference syntax must be distinguished from other SQL bind variables:
#[varname] This is the SQL bind variable syntax
$varname This is the SQL statement value substitution variable syntax
${varname} This is the non-SQL configuration The ioc file refers to the syntax reference document for external attribute variables: http://yin-bp.iteye.com/blog/2325602




Related documents: http://yin-bp.iteye.com/blog/1112887

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326692296&siteId=291194637