iBatis模具

Posted on 2007-04-07 16:48 它山の石 阅读(96) 评论(0)  编辑  收藏

SqlMapConfig.xml

 1<?xml version="1.0" encoding="UTF-8" ?>
 2<!DOCTYPE sqlMapConfig
 3PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
 4"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
 5<sqlMapConfig>
 6    <properties resource="com/sigon/ibatis/SqlMapConfig.properties" />
 7    <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" errorTracingEnabled="true" maxRequests="32" maxSessions="10" maxTransactions="5" useStatementNamespaces="false" />
 8    
 9    <transactionManager type="JDBC"  commitRequired="false">
10    <dataSource type="SIMPLE">
11        <property name="JDBC.Driver" value="${driver}" />
12        <property name="JDBC.ConnectionURL" value="${url}" />
13        <property name="JDBC.Username" value="${username}" />
14        <property name="JDBC.Password" value="${password}" />
15        <property name="Pool.MaximumActiveConnections" value="10" />
16        <property name="Pool.MaximumIdleConnections" value="5" />
17        <property name="Pool.MaximumWait" value="60000" />
18    </dataSource>
19    </transactionManager>
20    <sqlMap resource="com/sigon/ibatis/maps/User.xml" />
21</sqlMapConfig>
22
user.xml
 1<?xml version="1.0" encoding="UTF-8" ?>
 2<!DOCTYPE sqlMap
 3PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
 4"http://ibatis.apache.org/dtd/sql-map-2.dtd">
 5<sqlMap namespace="User">
 6
 7    <typeAlias alias="user" type="com.sigon.ibatis.User" />
 8    <select id="getUser" parameterClass="java.lang.String" resultClass="user">
 9        <![CDATA[ 
10    select    
11      name,    
12      sex    
13    from t_user    
14    where name = #name#    
15    ]]>
16    </select>
17
18    <select id="getAllUser" resultClass="user">
19        <![CDATA[
20    select 
21      id,   
22      name,    
23      sex    
24    from t_user
25    ]]>
26    </select>
27
28    <update id="updateUser" parameterClass="user">
29        <![CDATA[
30        UPDATE t_user SET name=#name#, sex=#sex# WHERE id = #id# ]]>
31    </update>
32
33    <insert id="insertUser" parameterClass="user">INSERT INTO t_user ( name, sex) VALUES ( #name#, #sex# )</insert>
34
35    <delete id="deleteUser" parameterClass="java.lang.String">delete from t_user where id=#value#</delete>
36<img src="http://www.blogjava.n