All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sqlmap.sqlmap-mapping-channel.xml Maven / Gradle / Ivy

<?xml version="1.0" encoding="UTF-8" ?>  
    <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"  
       "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<sqlMap namespace="com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO">
	<typeAlias alias="channel"
		type="com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO" />

	<resultMap id="channelResult" class="channel">
		<result property="id" column="ID" />
		<result property="name" column="NAME" />
		<result property="description" column="DESCRIPTION" />
		<result property="parameters" column="PARAMETERS" />
		<result property="gmtCreate" column="GMT_CREATE" />
		<result property="gmtModified" column="GMT_MODIFIED" />
	</resultMap>
	
	<resultMap id="channelPkResult" class="channel">
		<result property="id" column="ID" />
	</resultMap>

	<!-- all columns -->
	<sql id="allChannelColumns">ID,NAME,DESCRIPTION,PARAMETERS,GMT_CREATE,GMT_MODIFIED</sql>
	
	<sql id="channelPk">ID</sql>
	
	
	<select id="listChannelPks" resultMap="channelPkResult">
		select
		<include refid="channelPk" />
		from CHANNEL 
		<dynamic prepend="where">
			<isNotEmpty property="searchKey">
			NAME like concat('%',replace(#searchKey#,'_','\_'),'%') 
			or ID like concat('%',replace(#searchKey#,'_','\_'),'%')
			</isNotEmpty>
		</dynamic>
	
		ORDER BY ID DESC
		
		<dynamic>
			<isNotEmpty property="offset" >
				<isNotEmpty property="length">
					limit #offset#, #length#
				</isNotEmpty>
			</isNotEmpty>
		</dynamic>
	</select>	
	
	<select id="findChannelById" resultMap="channelResult"
		parameterClass="long">
		select
		<include refid="allChannelColumns" />
		from CHANNEL where ID = #value#
	</select>
	
	<select id="getChannelCount" resultClass="Integer">
		select count(*) from CHANNEL 
		<dynamic prepend="where">
			<isNotEmpty property="searchKey">
			NAME like concat('%',replace(#searchKey#,'_','\_'),'%') 
			or ID like concat('%',replace(#searchKey#,'_','\_'),'%')
			</isNotEmpty>
		</dynamic>
	</select>
	
	<select id="listChannelByIds" resultMap="channelResult" >
		select
		<include refid="allChannelColumns" />
		from CHANNEL where ID in
		<iterate open="(" close=")" conjunction=",">
			#[]#
		</iterate>
		ORDER BY ID DESC
	</select>	
	
	<select id="listChannels" resultMap="channelResult">
		select
		<include refid="allChannelColumns" />
		from CHANNEL 
		<dynamic prepend="where">
			<isNotEmpty property="searchKey">
			NAME like concat('%',replace(#searchKey#,'_','\_'),'%') 
			or ID like concat('%',replace(#searchKey#,'_','\_'),'%')
			</isNotEmpty>
		</dynamic>
	
		ORDER BY ID DESC
		
		<dynamic>
			<isNotEmpty property="offset" >
				<isNotEmpty property="length">
					limit #offset#, #length#
				</isNotEmpty>
			</isNotEmpty>
		</dynamic>
	</select>	


	<update id="updateChannel" parameterClass="channel">
		update CHANNEL
		set
		NAME=#name#,
		DESCRIPTION=#description#,
		PARAMETERS=#parameters#,
		GMT_MODIFIED=now()
		WHERE ID = #id#  
	</update>
	
	<select id="checkChannelUnique" resultClass="Integer"
		parameterClass="channel">
		select count(*) from CHANNEL
		where CHANNEL.ID != #id#
		and CHANNEL.NAME = #name#
	</select>
	
	<insert id="insertChannel" parameterClass="channel">
		insert into CHANNEL
		(NAME, DESCRIPTION,PARAMETERS, GMT_CREATE, GMT_MODIFIED)
		SELECT #name#,#description#,#parameters#,now(),now() 
		from dual
		WHERE not exists (select * from CHANNEL
		where CHANNEL.NAME = #name#); 
		<selectKey keyProperty="id" resultClass="long">
			select last_insert_id()
		</selectKey>
	</insert>
 
	<delete id="deleteChannelById" parameterClass="long">
    	delete from CHANNEL where ID = #value#
    </delete>

</sqlMap>  




© 2015 - 2025 Weber Informatics LLC | Privacy Policy