| <?xml version="1.0" encoding="UTF-8"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <!DOCTYPE sqlMap |
| PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" |
| "http://ibatis.apache.org/dtd/sql-map-2.dtd"> |
| |
| <sqlMap namespace="Account"> |
| |
| <!-- Use type aliases to avoid typing the full classname every time. --> |
| <typeAlias alias="Account" type="org.apache.camel.component.ibatis.Account"/> |
| |
| <!-- Result maps describe the mapping between the columns returned |
| from a query, and the class properties. A result map isn't |
| necessary if the columns (or aliases) match to the properties |
| exactly. --> |
| <resultMap id="AccountResult" class="Account"> |
| <result property="id" column="ACC_ID"/> |
| <result property="firstName" column="ACC_FIRST_NAME"/> |
| <result property="lastName" column="ACC_LAST_NAME"/> |
| <result property="emailAddress" column="ACC_EMAIL"/> |
| </resultMap> |
| |
| <!-- Select with no parameters using the result map for Account class. --> |
| <select id="selectAllAccounts" resultMap="AccountResult"> |
| select * from ACCOUNT order by ACC_ID |
| </select> |
| |
| <!-- A simpler select example without the result map. Note the |
| aliases to match the properties of the target result class. --> |
| <select id="selectAccountById" parameterClass="int" resultClass="Account"> |
| select |
| ACC_ID as id, |
| ACC_FIRST_NAME as firstName, |
| ACC_LAST_NAME as lastName, |
| ACC_EMAIL as emailAddress |
| from ACCOUNT |
| where ACC_ID = #id# |
| </select> |
| |
| <!-- Insert example, using the Account parameter class --> |
| <insert id="insertAccount" parameterClass="Account"> |
| insert into ACCOUNT ( |
| ACC_ID, |
| ACC_FIRST_NAME, |
| ACC_LAST_NAME, |
| ACC_EMAIL |
| ) |
| values ( |
| #id#, #firstName#, #lastName#, #emailAddress# |
| ) |
| </insert> |
| |
| <!-- Update example, using the Account parameter class --> |
| <update id="updateAccount" parameterClass="Account"> |
| update ACCOUNT set |
| ACC_FIRST_NAME = #firstName#, |
| ACC_LAST_NAME = #lastName#, |
| ACC_EMAIL = #emailAddress# |
| where |
| ACC_ID = #id# |
| </update> |
| |
| <!-- Delete example, using an integer as the parameter class --> |
| <delete id="deleteAccountById" parameterClass="int"> |
| delete from ACCOUNT where ACC_ID = #id# |
| </delete> |
| |
| <!-- START SNIPPET: e1 --> |
| <select id="selectUnprocessedAccounts" resultMap="AccountResult"> |
| select * from ACCOUNT where PROCESSED = false |
| </select> |
| <!-- END SNIPPET: e1 --> |
| |
| <select id="selectProcessedAccounts" resultMap="AccountResult"> |
| select * from ACCOUNT where PROCESSED = true |
| </select> |
| |
| <!-- START SNIPPET: e2 --> |
| <update id="consumeAccount" parameterClass="Account"> |
| update ACCOUNT set PROCESSED = true where ACC_ID = #id# |
| </update> |
| <!-- END SNIPPET: e2 --> |
| |
| <select id="count" resultClass="int"> |
| select count(*) from ACCOUNT |
| </select> |
| |
| </sqlMap> |