mybatis 应用
来源:互联网 发布:淘宝店怎样才有一颗心 编辑:程序博客网 时间:2024/06/13 21:27
利用mybatis的映射sql
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper namespace="com.qtbigdata.news.dao.newsinfo.NwInfoMapper"> <resultMap id="BaseResultMap" type="com.qtbigdata.news.model.NewsInfo"> <!-- 借用自动生成的mybatis Map --> <id column="id" jdbcType="INTEGER" property="id" /> <result column="news_id" jdbcType="BIGINT" property="newsId" /> <result column="articleType" jdbcType="TINYINT" property="articletype" /> <result column="title" jdbcType="VARCHAR" property="title" /> <result column="author" jdbcType="VARCHAR" property="author" /> <result column="artKeyword" jdbcType="VARCHAR" property="artkeyword" /> <result column="artAbstract" jdbcType="VARCHAR" property="artabstract" /> <result column="pubSource" jdbcType="VARCHAR" property="pubsource" /> <result column="copyrightSource" jdbcType="VARCHAR" property="copyrightsource" /> <result column="url" jdbcType="VARCHAR" property="url" /> <result column="urlMD5" jdbcType="VARCHAR" property="urlmd5" /> <result column="pubTime" jdbcType="TIMESTAMP" property="pubtime" /> <result column="webSiteId" jdbcType="INTEGER" property="websiteid" /> <result column="childSiteId" jdbcType="INTEGER" property="childsiteid" /> <result column="fingerprint" jdbcType="VARCHAR" property="fingerprint" /> <result column="moduleId" jdbcType="INTEGER" property="moduleid" /> <result column="sourceType" jdbcType="BIT" property="sourcetype" /> <result column="delFlag" jdbcType="BIT" property="delflag" /> <result column="createTime" jdbcType="BIGINT" property="createtime" /> <result column="userId" jdbcType="INTEGER" property="userid" /> <result column="lastUpEditor" jdbcType="INTEGER" property="lastupeditor" /> <result column="lastUpTime" jdbcType="TIMESTAMP" property="lastuptime" /> <result column="ext1" jdbcType="INTEGER" property="ext1" /> <result column="ext2" jdbcType="INTEGER" property="ext2" /> <result column="ext3" jdbcType="INTEGER" property="ext3" /> <result column="ext4" jdbcType="VARCHAR" property="ext4" /> <result column="ext5" jdbcType="VARCHAR" property="ext5" /> <result column="ext6" jdbcType="VARCHAR" property="ext6" /> <result column="ext7" jdbcType="VARCHAR" property="ext7" /> <result column="ext8" jdbcType="VARCHAR" property="ext8" /> </resultMap> <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.qtbigdata.news.model.NewsInfo"> <!-- 扩展解决返回类容过大的问题 返回的resultMap 定义完成--> <result column="content" jdbcType="LONGVARCHAR" property="content" /> </resultMap> <sql id="Base_Column_List"> <!-- 需要查询的字段,不包含content --> id, news_id, articleType, title, author, artKeyword, artAbstract, pubSource, copyrightSource, url, urlMD5, pubTime, webSiteId, childSiteId, fingerprint, moduleId, sourceType, delFlag, createTime, userId, lastUpEditor, lastUpTime, ext1, ext2, ext3, ext4, ext5, ext6, ext7, ext8 </sql> <sql id="Blob_Column_List"> <!-- 单独列出的blob内容 --> content </sql> <select id="selectByMapWithBLOBs" parameterType="java.util.Map" resultMap="ResultMapWithBLOBs"> <!--通过moduleId查询分页列表 --> SELECT <include refid="Base_Column_List" /> , <include refid="Blob_Column_List" /> FROM news_info WHERE 1=1 <if test="queryname != '' and queryname != null" > AND title LIKE concat(concat('%',#{queryname}),'%') </if> <if test="beginDate !='' and beginDate != null" > AND pubTime >=#{beginDate} </if> <if test="endDate !='' and endDate != null " > AND pubTime <=#{endDate} </if> <if test="moduleId != null"> AND moduleId =#{moduleId,jdbcType=INTEGER} </if> <if test="articleType != null"> AND articleType =#{articleType,jdbcType=INTEGER} </if> GROUP BY news_id ORDER BY pubTime desc lIMIT #{pageOffset},#{pageSize} </select> <select id="selectCountByParam" parameterType="java.util.Map" resultType="java.lang.Integer"> <!--通过moduleId查询去重的总记录 --> SELECT COUNT(distinct news_id)FROM news_info WHERE 1=1 <if test="moduleId != null" > AND moduleId =#{moduleId} </if> <if test="articleType != null"> AND articleType =#{articleType,jdbcType=INTEGER} </if> </select></mapper>另外一段配置mybatis数据的方法<!--2. 查询基础表,撮合表关联信息集合列表,用于系统数据导入 --> <select id="queryImportList" resultType="java.util.Map" parameterType="java.util.Map"> select tpbi.* , tbei.id tid, tbei.content context, tbei.is_include_cost, tbei.between_way, tbei.cost_type, tbei.contacts_name, tbei.contacts_phone, tbei.contacts_email, tbei.contacts_QQ, tbei.contacts_address, tbei.price from trademark_project_base_info tpbi left join trademark_between_entrust_info tbei on tpbi.id = tbei.project_base_info_id <where> <if test="designation != null and designation != ''"> tpbi.designation like CONCAT('%',#{designation},'%') </if> <if test="reg_no != null and reg_no != ''"> tpbi.reg_no like CONCAT('%',#{reg_no},'%') </if> <if test="contacts_name != null and contacts_name != ''"> tbei.contacts_name like CONCAT('%',#{contacts_name},'%') </if> <if test="contacts_phone != null and contacts_phone != ''"> tbei.contacts_phone like CONCAT('%',#{contacts_phone},'%') </if> <if test="starttime != null and starttime != ''"> and tpbi.addtime <![CDATA[>=]]> #{starttime} </if> <if test="endtime != null and endtime != ''"> and tpbi.addtime <![CDATA[<=]]> #{endtime} </if> </where> limit #{pageOffset},#{pageSize} </select>
0 0
- mybatis 应用
- mybatis 应用
- mybatis OGNL应用扩展
- Mybatis应用(oracle)
- mybatis分页应用
- mybatis OGNL应用
- mybatis的应用
- mybatis应用实例学习
- mybatis简单应用
- MyBatis 的简单应用
- sring mybatis 注解应用
- Mybatis的简单应用
- MyBatis简单应用
- Mybatis高级应用
- MyBatis入门应用
- MyBatis 的简单应用
- Mybatis高级应用
- Mybatis应用:Sql Annotation
- 关于这个博客
- P1012火柴棍等式
- 存储过程参考资料
- slidingMenu+百度地图 切换黑边解决方法
- 圆环
- mybatis 应用
- webuploader ie8 点击选择文件选择文件后,flash报错:flash没有exec函数
- Jsonp和java操作例子
- html5上传文件 file API -XMLHttpRequest 2 示例
- 显卡结构及工作原理详细解读
- ssh免密码登录问题分析
- 得到系统存储服务的方法
- CSS回顾-<a链接>伪类顺序
- 学习mybatis