Skip to content

Instantly share code, notes, and snippets.

@aziz781
Created November 3, 2011 14:36
Show Gist options
  • Save aziz781/1336642 to your computer and use it in GitHub Desktop.
Save aziz781/1336642 to your computer and use it in GitHub Desktop.
Spring iBatis sample sqlmap configuration file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL MAP 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<!-- Abdul Aziz -->
<sqlMap namespace="ObsClaim">
<resultMap id="claim-map" class="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<result property="obsId" column="OBS_ID" />
<result property="formId" column="FORM_ID" />
<result property="correlationId" column="CORRELATION_ID" />
<result property="assigned" column="ASSIGNED" />
<result property="state" column="STATE" />
<result property="status" column="STATUS" />
<result property="assignedTo" column="ASSIGNED_TO" />
<result property="responseCode" column="RESPONSE_CODE" />
<result property="responseText" column="RESPONSE_TEXT" />
<result property="dateReceived" column="DATE_RECEIVED" />
<result property="dateModified" column="DATE_MODIFIED" />
<result property="modifiedBy" column="MODIFIED_BY" />
</resultMap>
<insert id="create" parameterClass="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<selectKey keyProperty="obsId" type="pre" resultClass="Long">
SELECT OBS_CLAIMS_INQUEUE_SEQ.NEXTVAL as value FROM DUAL
</selectKey>
<![CDATA[
INSERT INTO OBS_CLAIMS_INQUEUE
(
OBS_ID,
FORM_ID,
CORRELATION_ID,
ASSIGNED,
STATE,
STATUS,
DATE_RECEIVED
)
VALUES
(
#obsId#,
#formId#,
#correlationId#,
#assigned#,
#state#,
#status#,
#dateReceived#
)
]]>
</insert>
<select id="selectById" parameterClass="long" resultMap="ObsClaim.claim-map">
<![CDATA[
SELECT *
FROM OBS_CLAIMS_INQUEUE s
WHERE s.OBS_ID = #value#
]]>
</select>
<select id="selectByUserId" parameterClass="String" resultMap="ObsClaim.claim-map">
<![CDATA[
SELECT *
FROM OBS_CLAIMS_INQUEUE s
WHERE ASSIGNED_TO = #assignedTo#
]]>
</select>
<select id="selectAll" resultMap="ObsClaim.claim-map">
<![CDATA[
SELECT *
FROM OBS_CLAIMS_INQUEUE s
]]>
</select>
<select id="countAll" resultClass="int">
<![CDATA[
SELECT count(1)
FROM OBS_CLAIMS_INQUEUE
]]>
</select>
<delete id="delete" parameterClass="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<![CDATA[
DELETE FROM OBS_CLAIMS_INQUEUE s WHERE s.OBS_ID = #obsId#
]]>
</delete>
<update id="lock" parameterClass="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<![CDATA[
UPDATE OBS_CLAIMS_INQUEUE
SET
STATE = #state#,
STATUS = #status#,
ASSIGNED = #assigned# ,
ASSIGNED_TO = #assignedTo#
WHERE OBS_ID = #obsId# and
STATE != #state# and
STATUS != #status# and
ASSIGNED != #assigned# and
ASSIGNED_TO IS NULL
]]>
</update>
<update id="update" parameterClass="uk.gov.nhsbsa.dcss.obs.domain.ObsClaim">
<![CDATA[
UPDATE OBS_CLAIMS_INQUEUE
SET
STATE = #state#,
STATUS = #status#,
RESPONSE_CODE=#responseCode#,
RESPONSE_TEXT=#responseText#,
ASSIGNED = #assigned#,
ASSIGNED_TO = #assignedTo#,
DATE_MODIFIED = #dateModified#,
MODIFIED_BY = #modifiedBy#
WHERE OBS_ID = #obsId# and
STATE != #state# and
STATUS != #status# and
ASSIGNED != #assigned# and
ASSIGNED_TO IS NOT NULL
]]>
</update>
<select id="findClaims" resultMap="ObsClaim.claim-map">
<![CDATA[
SELECT *
FROM OBS_CLAIMS_INQUEUE c
WHERE c.ASSIGNED = #ASSIGNED# AND
c.STATE like #STATE# AND
c.STATUS like #STATUS# AND
c.ASSIGNED_To IS NULL
order by OBS_ID ASC
]]>
</select>
</sqlMap>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment