ibatis学习笔记(三)>>>>>>>java实体跟表映射.xml文件详解
来源:互联网 发布:网络准入控制登录 编辑:程序博客网 时间:2024/05/16 08:48
在项目中使用Ibatis难免会使用到java实体跟表映射.xml.
<?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="ALARM_CAUSE" >
<typeAlias type="com.metarnet.ipnms.alarm.model.AlarmCause" alias="alarmCause"/> <!-- 给实体类的一个别名,方面下文引用-->
<resultMap id="AlarmCauseResult" class="alarmCause" > <!-- javabean 跟数据库表列的映射-->
<result column="CAUSE_ID" property="causeId" jdbcType="DECIMAL" />
<result column="CAUSE_NAME" property="causeName" jdbcType="VARCHAR" />
<result column="CAUSE_NAME_CN" property="causeNameCn" jdbcType="VARCHAR" />
<result column="ALARM_LEVEL" property="alarmLevel" />
<result column="LEVEL_NAME" property="levelName" jdbcType="VARCHAR" />
<result column="CAUSE_NAME_CN" property="causeNameCn" jdbcType="VARCHAR" />
<result column="ALARM_DESC" property="alarmDesc" jdbcType="VARCHAR" />
<result column="RESID" property="resid" jdbcType="VARCHAR" />
</resultMap>
<sql id="ALARM_CAUSE_Example_Where_Clause" ><!-- 动态的生成SQL -->
<iterate property="oredCriteria" conjunction="or" prepend="where" removeFirstPrepend="iterate" >
<isEqual property="oredCriteria[].valid" compareValue="true" >
(
<iterate prepend="and" property="oredCriteria[].criteriaWithoutValue" conjunction="and" >
$oredCriteria[].criteriaWithoutValue[]$
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >
$oredCriteria[].criteriaWithSingleValue[].condition$
#oredCriteria[].criteriaWithSingleValue[].value#
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithListValue" conjunction="and" >
$oredCriteria[].criteriaWithListValue[].condition$
<iterate property="oredCriteria[].criteriaWithListValue[].values" open="(" close=")" conjunction="," >
#oredCriteria[].criteriaWithListValue[].values[]#
</iterate>
</iterate>
<iterate prepend="and" property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >
$oredCriteria[].criteriaWithBetweenValue[].condition$
#oredCriteria[].criteriaWithBetweenValue[].values[0]# and
#oredCriteria[].criteriaWithBetweenValue[].values[1]#
</iterate>
)
</isEqual>
</iterate>
</sql>
<!-- 查询语句标签 返回一个结果集 如果返回多个结果集则用 resultMap 如果返回单个结果集则用resultClass="AlarmCauseResult" -->
<select id="ALARM_CAUSE_selectAllAlarmCause" resultMap="AlarmCauseResult">
<!-- select statement -->
</select>
<!-- 删除语句标签 在ibatis中默认的删除语句是 返回数据库受影响的行数 -->
<delete id="ALARM_CAUSE_deleteByPrimaryKey" parameterClass="com.metarnet.ipnms.alarm.model.AlarmCause" >
<!-- delete statement -->
</delete>
<!--新增语句标签 返回数据库受影响的行数 -->
<insert id="ALARM_CAUSE_insert" parameterClass="com.metarnet.ipnms.alarm.model.AlarmCause" >
<!-- insertstatement --> </insert>
<!--修改语句标签 返回数据库受影响的行数 -->
<update id="ALARM_CAUSE_updateByPrimaryKey" parameterClass="com.metarnet.ipnms.alarm.model.AlarmCause">
<!-- update statement -->
</update>
<procedure id="ALARM_CAUSE_getById" parameterMap="" >
{? = call alarm.getSingleDetailRows(?)}
</procedure>
</sqlMap>
java实体跟数据库表的映射到此结束了。
- ibatis学习笔记(三)>>>>>>>java实体跟表映射.xml文件详解
- ibatis学习笔记(三)>>>>>>>java实体跟表映射.xml文件详解
- ibatis实体sql映射文件
- ibatis学习笔记(一)>>>>>>>sqlMapConfig.xml文件详解
- ibatis学习笔记(二)>>>>>>>sqlMapConfig.xml文件详解
- ibatis学习笔记(一)>>>>>>>sqlMapConfig.xml文件详解
- ibatis学习笔记(二)>>>>>>>sqlMapConfig.xml文件详解
- 【Ibatis】(三)、ibatis映射文件
- iBatis映射文件详解(一)
- Struts2学习笔记(三):struts.xml文件详解
- hbm.xml 映射文件参数学习笔记
- iBatis 之 SQL Map XML映射文件
- 实体xml文件映射多对多
- ibatis学习笔记-插入一个实体对象
- ibatis学习笔记-修改实体对象
- ibatis学习笔记-模糊查询实体对象
- iBatis.Net系列(三) 映射文件基础
- iBatis.Net系列(三) 映射文件基础
- SQL Server2008存储结构之基本系统视图(转)
- 纪念20110325
- 转:Java内部类
- 有用的工具集锦
- 2、ETL抽取数据子系统
- ibatis学习笔记(三)>>>>>>>java实体跟表映射.xml文件详解
- Mark Recchi Comments About Max Pacioretty's Injury Hold NHL Back
- 图形界面应用展示一个立方体和球体 -可以将java3d图形生成图片文件
- JDIC浏览器组件的使用方法(将网页在swing界面上显示)
- Philadelphia Flyers: NHL Playoff Previews with Potential 1st-Round Opponents
- TUP系列活动第八期:HTML5技术应用分享
- (转)C++总结 ----- 虚函数和多态性(一)
- 代码4
- c++自增自减问题 自增自减运算符