- 浏览: 55043 次
- 性别:
- 来自: 深圳
文章分类
最新评论
# <?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="Account">
# <typeAlias alias="Account" type="test.Account"/>
# <!--列表查询,返回Account Object的List-->
# <resultMap id="AccountResult" class="Account">
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# </resultMap>
# <select id="selectAllAccounts" resultMap="AccountResult">
# select * from ACCOUNT
# </select>
#
# <!--列表查询,返回HashMap的List -->
# <!--resultMap无需再通过JDBC ResultSetMetaData 来动态获取字段信息,性能有提高-->
#
# <resultMap id="mapResult" class="java.util.HashMap">
# <result property="roleid" column="ROLEID"/>
# <result property="rolename" column="ROLENAME"/>
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# <result property="dt" column="DT"/>
# </resultMap>
# <select id="selectAllAccountsWithMap" resultMap="mapResult">
# select B.ROLEID, B.ROLENAME, A.ID, A.FIRST_NAME,A.LAST_NAME,A.EMAIL,A.DT
# from ACCOUNT A left outer join ROLE B on A.ROLEID = B.ROLEID
# ORDER BY A.ID DESC
# </select>
#
# <!--动态构造查询条件-->
# <select id="getUsers" parameterClass="user" resultMap="get-user-result">
# Select id,name,sex from t_user
# <dynamic prepend="WHERE">
# <isNotEmpty prepend="AND" property="name">
# (name like #name#)
# </isNotEmpty>
# <isNotEmpty prepend="AND" property="address">
# (address like #address#)
# </isNotEmpty>
# </dynamic>
# </select>
# <isNotEmpty prepend="AND" property="name">
# ( name=#name#
# <isNotEmpty prepend="AND" property="address">
# address=#address#
# </isNotEmpty>
# )
# </isNotEmpty>
# <select id="dynamicGetAccountList" resultMap="account-result" >
# select * from ACCOUNT
# <dynamic prepend="WHERE">
# <isNotNull prepend="AND" property="firstName" open=”(“ close=”)”>
# ACC_FIRST_NAME = #firstName#
# <isNotNull prepend="OR" property="lastName">
# ACC_LAST_NAME = #lastName#
# </isNotNull>
# </isNotNull>
# <isNotNull prepend="AND" property="emailAddress">
# ACC_EMAIL like #emailAddress#
# </isNotNull>
# <isGreaterThan prepend="AND" property="id" compareValue="0">
# ACC_ID = #id#
# </isGreaterThan>
# </dynamic>
# order by ACC_LAST_NAME
# </select>
#
# <isParameterPresent> <isNotParameterPresent> <isNull> <isNotNull> <isEmpty> <isNotEmpty>
# <isEqual> <isNotEqual> <isGreaterThan> <isGreaterEqual> <isLessThan> <isLessEqual>
#
# <!-- Sql片段的是用-->
# <sql id="selectItem_fragment">
# FROM items WHERE parentid = 6
# </sql>
# <select id="selectItemCount" resultClass="int">
# SELECT COUNT(*) AS total
# <include refid="selectItem_fragment"/>
# </select>
# <select id="selectItems" resultClass="Item">
# SELECT id, name
# <include refid="selectItem_fragment"/>
# </select>
#
# <!--缓存-->
# <cacheModel id="product-cache" type="LRU">
# <flushInterval hours="24"/>
# <flushOnExecute statement="insertProduct"/>
# <flushOnExecute statement="updateProduct"/>
# <flushOnExecute statement="deleteProduct"/>
# <property name=”size” value=”1000” />
# </cacheModel>
# <select id=”getProductList” parameterClass=”int” cacheModel=”product-cache”>
# select * from PRODUCT where PRD_CAT_ID = #value#
# </select>
#
# <!—对XML支持 -->
# <select id="getPerson" parameterClass=”int” resultClass="xml" xmlResultName=”person”>
# SELECT
# PER_ID as id,
# PER_FIRST_NAME as firstName,
# PER_LAST_NAME as lastName,
# PER_BIRTH_DATE as birthDate,
# PER_WEIGHT_KG as weightInKilograms,
# PER_HEIGHT_M as heightInMeters
# FROM PERSON
# WHERE PER_ID = #value#
# </select>
# <person>
# <id>1</id>
# <firstName>Clinton</firstName>
# <lastName>Begin</lastName>
# <birthDate>1900-01-01</birthDate>
# <weightInKilograms>89</weightInKilograms>
# <heightInMeters>1.77</heightInMeters>
# </person>
#
# <!—字符串替换
# select * from $tableName$
# Important Note 1: This support will only substitute Strings, so it is not appropriate for complex data types like Date or Timestamp.
# Important Note 2: If you use this support to alter a table name, or a column list, in an SQL select statement,then you should always specify remapResults=“true”
# -->.
#
# <!—关联查询方式,有1/N问题-->
# <sqlMap namespace="User">
# <typeAlias alias="user" type="com.ibatis.sample.User"/>
# <typeAlias alias="address" type="com.ibatis.sample.Address"/>
# <resultMap id="get-user-result" class="user">
# <result property="id" column="id"/>
# <result property="name" column="name"/>
# <result property="sex" column="sex"/>
# <result property="addresses" column="id" select="User.getAddressByUserId"/>
# </resultMap>
# <select id="getUsers" parameterClass="java.lang.String" resultMap="get-user-result">
# <![CDATA[Select id,name,sex from t_user where id = #id#]]>
# </select>
# <select id="getAddressByUserId" parameterClass="int" resultClass="address">
# <![CDATA[select address,zipcode from t_address where user_id = #userid# ]]>
# </select>
# </sqlMap>
# <resultMap id="get-user-result" class="user">
# <result property="id" column="id"/>
# <result property="name" column="name"/>
# <result property="sex" column="sex"/>
# <result property="address" column="t_address.address"/>
# <result property="zipCode" column="t_address.zipcode"/>
# </resultMap>
# <select id="getUsers" parameterClass="java.lang.String" resultMap="get-user-result">
# <![CDATA[select* from t_user,t_address where t_user.id=t_address.user_id]]>
# </select>
# 保证User 类中包含address和zipCode两个String型属性。
#
# <!—关联查询,无1/N问题-->
# <resultMap id="AccountResultWithRole" class="Account" groupBy="id">
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# <result property="role" resultMap="Account.roleResult"/>
# </resultMap>
# <resultMap id="roleResult" class="test.Role">
# <result property="roleid" column="ROLEID"/>
# <result property="rolename" column="ROLENAME"/>
# </resultMap>
# <select id="selectAccountByIdWithRole" parameterClass="int" resultMap="AccountResultWithRole">
# select B.ROLEID, B.ROLENAME, A.ID, A.FIRST_NAME,A.LAST_NAME,A.EMAIL from ACCOUNT A left outer join ROLE B on A.ROLEID = B.ROLEID where A.ID = #id#
# </select>
#
# <!--查询-->
# <select id="selectAccountById" parameterClass="int" resultClass="Account">
# select ID as id,FIRST_NAME as firstName,LAST_NAME as lastName, EMAIL as emailAddress from ACCOUNT where ID = #id#
# </select>
#
# <!--新增-->
# <insert id="insertAccount" parameterClass="Account">
# insert into ACCOUNT (FIRST_NAME,LAST_NAME,EMAIL,PID,DT)
# values (#firstName:VARCHAR#, #lastName:VARCHAR#, #emailAddress:VARCHAR#,#pid:INTEGER:0#,#dt:TIME#)
# <selectKey resultClass="int" type="post" keyProperty="id">
# SELECT @@IDENTITY AS ID
# </selectKey>
# </insert>
#
# <!--更新-->
# <update id="updateAccount" parameterClass="Account">
# update ACCOUNT set
# FIRST_NAME = #firstName:VARCHAR#,
# LAST_NAME = #lastName:VARCHAR#,
# EMAIL = #emailAddress:VARCHAR#
# where
# ID = #id#
# </update>
#
# <!--删除-->
# <delete id="deleteAccountById" parameterClass="int">
# delete from ACCOUNT where ID = #id#
# </delete>
#
# <!--存储过程,如果没有返回列表,procTest的resultMap可以省略-->
# <parameterMap id="procParamMap" class="java.util.HashMap" >
# <parameter property="id" jdbcType="INTEGER" javaType="java.lang.Integer" mode="IN"/>
# <parameter property="outid" jdbcType="INTEGER" javaType="java.lang.Integer" mode="OUT"/>
# <parameter property="errMsg" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
# </parameterMap>
# <resultMap id="procResultMap" class="java.util.HashMap" >
# <result property="a" column="AAA"/>
# <result property="b" column="BBB"/>
# <result property="c" column="CCC"/>
# </resultMap>
# <procedure id="procTest" parameterMap="procParamMap" resultMap="procResultMap">
# {call test_sp_1 (?,?,?)}
# </procedure>
# </sqlMap>
# <!DOCTYPE sqlMap
# PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
# "http://ibatis.apache.org/dtd/sql-map-2.dtd">
# <sqlMap namespace="Account">
# <typeAlias alias="Account" type="test.Account"/>
# <!--列表查询,返回Account Object的List-->
# <resultMap id="AccountResult" class="Account">
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# </resultMap>
# <select id="selectAllAccounts" resultMap="AccountResult">
# select * from ACCOUNT
# </select>
#
# <!--列表查询,返回HashMap的List -->
# <!--resultMap无需再通过JDBC ResultSetMetaData 来动态获取字段信息,性能有提高-->
#
# <resultMap id="mapResult" class="java.util.HashMap">
# <result property="roleid" column="ROLEID"/>
# <result property="rolename" column="ROLENAME"/>
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# <result property="dt" column="DT"/>
# </resultMap>
# <select id="selectAllAccountsWithMap" resultMap="mapResult">
# select B.ROLEID, B.ROLENAME, A.ID, A.FIRST_NAME,A.LAST_NAME,A.EMAIL,A.DT
# from ACCOUNT A left outer join ROLE B on A.ROLEID = B.ROLEID
# ORDER BY A.ID DESC
# </select>
#
# <!--动态构造查询条件-->
# <select id="getUsers" parameterClass="user" resultMap="get-user-result">
# Select id,name,sex from t_user
# <dynamic prepend="WHERE">
# <isNotEmpty prepend="AND" property="name">
# (name like #name#)
# </isNotEmpty>
# <isNotEmpty prepend="AND" property="address">
# (address like #address#)
# </isNotEmpty>
# </dynamic>
# </select>
# <isNotEmpty prepend="AND" property="name">
# ( name=#name#
# <isNotEmpty prepend="AND" property="address">
# address=#address#
# </isNotEmpty>
# )
# </isNotEmpty>
# <select id="dynamicGetAccountList" resultMap="account-result" >
# select * from ACCOUNT
# <dynamic prepend="WHERE">
# <isNotNull prepend="AND" property="firstName" open=”(“ close=”)”>
# ACC_FIRST_NAME = #firstName#
# <isNotNull prepend="OR" property="lastName">
# ACC_LAST_NAME = #lastName#
# </isNotNull>
# </isNotNull>
# <isNotNull prepend="AND" property="emailAddress">
# ACC_EMAIL like #emailAddress#
# </isNotNull>
# <isGreaterThan prepend="AND" property="id" compareValue="0">
# ACC_ID = #id#
# </isGreaterThan>
# </dynamic>
# order by ACC_LAST_NAME
# </select>
#
# <isParameterPresent> <isNotParameterPresent> <isNull> <isNotNull> <isEmpty> <isNotEmpty>
# <isEqual> <isNotEqual> <isGreaterThan> <isGreaterEqual> <isLessThan> <isLessEqual>
#
# <!-- Sql片段的是用-->
# <sql id="selectItem_fragment">
# FROM items WHERE parentid = 6
# </sql>
# <select id="selectItemCount" resultClass="int">
# SELECT COUNT(*) AS total
# <include refid="selectItem_fragment"/>
# </select>
# <select id="selectItems" resultClass="Item">
# SELECT id, name
# <include refid="selectItem_fragment"/>
# </select>
#
# <!--缓存-->
# <cacheModel id="product-cache" type="LRU">
# <flushInterval hours="24"/>
# <flushOnExecute statement="insertProduct"/>
# <flushOnExecute statement="updateProduct"/>
# <flushOnExecute statement="deleteProduct"/>
# <property name=”size” value=”1000” />
# </cacheModel>
# <select id=”getProductList” parameterClass=”int” cacheModel=”product-cache”>
# select * from PRODUCT where PRD_CAT_ID = #value#
# </select>
#
# <!—对XML支持 -->
# <select id="getPerson" parameterClass=”int” resultClass="xml" xmlResultName=”person”>
# SELECT
# PER_ID as id,
# PER_FIRST_NAME as firstName,
# PER_LAST_NAME as lastName,
# PER_BIRTH_DATE as birthDate,
# PER_WEIGHT_KG as weightInKilograms,
# PER_HEIGHT_M as heightInMeters
# FROM PERSON
# WHERE PER_ID = #value#
# </select>
# <person>
# <id>1</id>
# <firstName>Clinton</firstName>
# <lastName>Begin</lastName>
# <birthDate>1900-01-01</birthDate>
# <weightInKilograms>89</weightInKilograms>
# <heightInMeters>1.77</heightInMeters>
# </person>
#
# <!—字符串替换
# select * from $tableName$
# Important Note 1: This support will only substitute Strings, so it is not appropriate for complex data types like Date or Timestamp.
# Important Note 2: If you use this support to alter a table name, or a column list, in an SQL select statement,then you should always specify remapResults=“true”
# -->.
#
# <!—关联查询方式,有1/N问题-->
# <sqlMap namespace="User">
# <typeAlias alias="user" type="com.ibatis.sample.User"/>
# <typeAlias alias="address" type="com.ibatis.sample.Address"/>
# <resultMap id="get-user-result" class="user">
# <result property="id" column="id"/>
# <result property="name" column="name"/>
# <result property="sex" column="sex"/>
# <result property="addresses" column="id" select="User.getAddressByUserId"/>
# </resultMap>
# <select id="getUsers" parameterClass="java.lang.String" resultMap="get-user-result">
# <![CDATA[Select id,name,sex from t_user where id = #id#]]>
# </select>
# <select id="getAddressByUserId" parameterClass="int" resultClass="address">
# <![CDATA[select address,zipcode from t_address where user_id = #userid# ]]>
# </select>
# </sqlMap>
# <resultMap id="get-user-result" class="user">
# <result property="id" column="id"/>
# <result property="name" column="name"/>
# <result property="sex" column="sex"/>
# <result property="address" column="t_address.address"/>
# <result property="zipCode" column="t_address.zipcode"/>
# </resultMap>
# <select id="getUsers" parameterClass="java.lang.String" resultMap="get-user-result">
# <![CDATA[select* from t_user,t_address where t_user.id=t_address.user_id]]>
# </select>
# 保证User 类中包含address和zipCode两个String型属性。
#
# <!—关联查询,无1/N问题-->
# <resultMap id="AccountResultWithRole" class="Account" groupBy="id">
# <result property="id" column="ID"/>
# <result property="firstName" column="FIRST_NAME"/>
# <result property="lastName" column="LAST_NAME"/>
# <result property="emailAddress" column="EMAIL"/>
# <result property="role" resultMap="Account.roleResult"/>
# </resultMap>
# <resultMap id="roleResult" class="test.Role">
# <result property="roleid" column="ROLEID"/>
# <result property="rolename" column="ROLENAME"/>
# </resultMap>
# <select id="selectAccountByIdWithRole" parameterClass="int" resultMap="AccountResultWithRole">
# select B.ROLEID, B.ROLENAME, A.ID, A.FIRST_NAME,A.LAST_NAME,A.EMAIL from ACCOUNT A left outer join ROLE B on A.ROLEID = B.ROLEID where A.ID = #id#
# </select>
#
# <!--查询-->
# <select id="selectAccountById" parameterClass="int" resultClass="Account">
# select ID as id,FIRST_NAME as firstName,LAST_NAME as lastName, EMAIL as emailAddress from ACCOUNT where ID = #id#
# </select>
#
# <!--新增-->
# <insert id="insertAccount" parameterClass="Account">
# insert into ACCOUNT (FIRST_NAME,LAST_NAME,EMAIL,PID,DT)
# values (#firstName:VARCHAR#, #lastName:VARCHAR#, #emailAddress:VARCHAR#,#pid:INTEGER:0#,#dt:TIME#)
# <selectKey resultClass="int" type="post" keyProperty="id">
# SELECT @@IDENTITY AS ID
# </selectKey>
# </insert>
#
# <!--更新-->
# <update id="updateAccount" parameterClass="Account">
# update ACCOUNT set
# FIRST_NAME = #firstName:VARCHAR#,
# LAST_NAME = #lastName:VARCHAR#,
# EMAIL = #emailAddress:VARCHAR#
# where
# ID = #id#
# </update>
#
# <!--删除-->
# <delete id="deleteAccountById" parameterClass="int">
# delete from ACCOUNT where ID = #id#
# </delete>
#
# <!--存储过程,如果没有返回列表,procTest的resultMap可以省略-->
# <parameterMap id="procParamMap" class="java.util.HashMap" >
# <parameter property="id" jdbcType="INTEGER" javaType="java.lang.Integer" mode="IN"/>
# <parameter property="outid" jdbcType="INTEGER" javaType="java.lang.Integer" mode="OUT"/>
# <parameter property="errMsg" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
# </parameterMap>
# <resultMap id="procResultMap" class="java.util.HashMap" >
# <result property="a" column="AAA"/>
# <result property="b" column="BBB"/>
# <result property="c" column="CCC"/>
# </resultMap>
# <procedure id="procTest" parameterMap="procParamMap" resultMap="procResultMap">
# {call test_sp_1 (?,?,?)}
# </procedure>
# </sqlMap>
发表评论
-
Hibernate程序性能优化
2008-08-10 21:40 632初用HIBERNATE的人也许都遇到过性能问题,实现同一功能, ... -
Hibernate性能优化4( 转)
2008-08-10 15:57 784关键字: hibernate 本文依照HIBERNATE帮助 ... -
Hibernate性能优化3( 转)
2008-08-10 15:56 715作者:Robbin Fan 一。 inverse = ? ... -
Hibernate性能优化2( 转)
2008-08-10 15:55 737在处理大数据量时,会 ... -
Hibernate性能优化
2008-08-10 15:48 1020有很多人认为Hibernate天 ...
相关推荐
**Ibatis小结** Ibatis,一款轻量级的Java持久层框架,是MyBatis的前身,由Clinton Begin在2003年创建。它致力于解决Java应用程序中的数据访问层(DAL)问题,提供了SQL映射框架,使得开发者可以直接编写SQL语句,...
### ibatis 学习小结笔记 #### 一、ibatis 概述 ibatis 是一个基于 Java 的持久层框架,它提供了一种简便的方式来处理关系型数据库与 Java 对象之间的映射(O/R Mapping)。ibatis 在设计上强调的是 SQL 语句的...
IBATIS是一个开源的ORM(Object-Relational Mapping)框架,最初由Java版本发展而来,后来移植到了.NET平台,成为IBatis.Net。它允许开发者将SQL语句与业务逻辑对象分离,以XML文件的形式存储SQL映射,提高代码的可...
1.5 小结 24 第2章 iBATIS是什么 26 2.1 映射SQL语句 27 2.2 iBATIS如何工作 29 2.2.1 iBATIS之于小型、简单系统 30 2.2.2 iBATIS之于大型、企业级系统 31 2.3 为何使用iBATIS 31 2.3.1 简单性 32 2.3.2 生产效率 ...
通过提供的文件《IBatisNet开发使用小结.docx》和《iBatis[1].Net详细使用手册.docx》,你将能够找到具体的步骤和示例代码,这些实例将涵盖基本的CRUD操作(创建、读取、更新和删除),以及更高级的功能如存储过程...
每个章节末尾都有小结和练习题,加深理解并鼓励读者动手实践。书中的案例涵盖了各种常见应用场景,如单表操作、多表关联查询、批量更新等,全面展示了iBatis在实际开发中的应用。 总之,《iBatis in Action》是学习...
### SSI框架整合小结 #### 一、概述 本文旨在详细介绍在SSI(Struts + Spring + iBatis)框架下的整体运作流程。通过本文,读者可以了解到在SSI框架环境中,每一项具体操作是如何被各个组件所处理和执行的。 ####...
1.5 本章小结 第2章 SQL语句基础之DDL 2.1 DDL基础 2.2 DDL操作视图 2.3 本章小结 第3章 SQL语句基础之DML 3.1 SELECT语句基础 3.2 WHERE子句 3.3 ORDER BY子句 3.4 GROUP BY和HAVING子句 3.5 ...
JAVA模块知识小结涵盖的内容非常广泛,包含了Java技术栈中的多个重要知识点,从基础的开发工具到框架、数据库以及编程语言本身,以下是对给定文件中提到的各项技术的详细知识点梳理: 1. Hibernate和Ibatis ...
1.5 小结 第2章 myedipse开发工具对各种框架的支持 2.1 使用jsp的两种模式 2.2 struts框架的实现 2.3 hibernate框架的实现 2.4 jpa框架的实现 2.5 spring框架的实现 2.6 jsf框架的实现 2.7...
- **Spring与iBatis的集成**:通过Spring管理DAO层的Bean,使得iBatis更加灵活地被应用于数据访问操作中。 #### 三、开发环境搭建 ##### 1. 开发工具 - **Eclipse 3.6**:主流的Java集成开发环境之一。 - **...
这篇实习小结主要涵盖了计算机软件实习的一些核心要点,包括实习的目的、实习地点、实习时间、实习内容以及实习过程中的挑战和解决方法。以下是对这些知识点的详细说明: 1. **实习目的**:实习的主要目标是将所学...
在【优秀计算机软件实习小结模板】中,实习地点是深圳市百盛佳信息咨询有限公司,实习时间为20__年12月5日至20__年4月5日。实习内容涉及Java软件开发,这是一种广泛使用的编程语言,尤其适合构建企业级应用。在实习...
本文将根据《J2EE开发架构小结》的文件内容,深入探讨J2EE开发架构的多种实现方式,以及每种架构的特点和应用场景。 ### 宏观架构视角 在宏观层面,J2EE架构遵循分层原则,通常分为表现层、业务层、访问层和资源层...
目录 第一部分spring的核心 第1章开始spring之旅 1.1spring是什么 1.2开始spring之旅 1.3理解依赖注入 ...1.5小结 ...2.6小结 ...3.7小结 ...4.6小结 ...5.6spring和ibatis ...5.6.1配置ibatis客户模板 ...b.4小结
第一部分 Spring的核心 第1章 开始Spring之旅 1.1 Spring是什么 1.2 开始Spring之旅 1.3 理解依赖注入 1.3.1 依赖注入 1.3.2 DI应用 1.3.3 企业级应用中的依赖注入 1.4 应用AOP ...B.4 小结
第一部分 Spring的核心 第1章 开始Spring之旅 1.1 Spring是什么 1.2 开始Spring之旅 1.3 理解依赖注入 1.3.1 依赖注入 1.3.2 DI应用 1.3.3 企业级应用中的依赖注入 1.4 应用AOP ...B.4 小结