当前位置: 首页 > news >正文

四川建设行业网站有哪些网络营销的几种模式

四川建设行业网站有哪些,网络营销的几种模式,孝感个人网站建设,b9b2comn深夜福科a8a6resultMap 表示查询结果集与java对象之间的一种关系,处理查询结果集,映射到java对象。 resultMap 是一种“查询结果集---Bean对象”属性名称映射关系,使用resultMap关系可将将查询结果集中的列一一映射到bean对象的各个属性&#…

resultMap      


    表示查询结果集与java对象之间的一种关系,处理查询结果集,映射到java对象。     

       resultMap 是一种“查询结果集---Bean对象”属性名称映射关系,使用resultMap关系可将将查询结果集中的列一一映射到bean对象的各个属性(两者属性名可以不同,配置好映射关系即可),适用与复杂一点的查询。

(1)适用于表的连接查询(在resultMap里面可以配置连接条件,见如下程序association标签)
 

<!-- 订单查询关联用户的resultMap将整个查询的结果映射到cn.itcast.mybatis.po.Orders中   -->  <resultMap type="cn.itcast.mybatis.po.Orders" id="OrdersUserResultMap">  <!-- 配置映射的订单信息 -->  <!-- id:指定查询列中的唯 一标识,订单信息的中的唯 一标识,如果有多个列组成唯一标识,配置多个id ,column:订单信息的唯 一标识列 ,property:订单信息的唯 一标识 列所映射到Orders中哪个属性  -->  <id column="id" property="id"/><result column="user_id" property="userId"/> <result column="number" property="number"/> <result column="createtime" property="createtime"/><result column="note" property=note/>          <!-- 配置映射的关联的用户信息 --> <!-- association:用于映射关联查询单个对象的信息property:要将关联查询的用户信息映射到Orders中哪个属性 -->  <association property="user"  javaType="cn.itcast.mybatis.po.User"><!-- id:关联查询用户的唯 一标识column:指定唯 一标识用户信息的列javaType:映射到user的哪个属性--><id column="user_id" property="id"/><result column="username" property="username"/><result column="sex" property="sex"/><result column="address" property="address"/></association> </resultMap>

2)适用于表的一对多连接查询,(如,订单对应多个订单明细时,需要根据连接条件订单id匹配订单明细,并且消除重复的订单信息(订单明细中的),如下程序);

<resultMap type="cn.itcast.mybatis.po.Orders" id="OrdersAndOrderDetailResultMap" extends="OrdersUserResultMap"><!-- 订单信息 --> <!-- 用户信息 --><!-- 使用extends继承,不用在中配置订单信息和用户信息的映射 --><!-- 订单明细信息一个订单关联查询出了多条明细,要使用collection进行映射collection:对关联查询到多条记录映射到集合对象中property:将关联查询到多条记录映射到cn.itcast.mybatis.po.Orders哪个属性 ofType:指定映射到list集合属性中pojo的类型 -->  <collection property="orderdetails" ofType="cn.itcast.mybatis.po.Orderdetail"><!-- id:订单明细唯 一标识 property:要将订单明细的唯 一标识 映射到cn.itcast.mybatis.po.Orderdetail的哪个属性-->  <id column="orderdetail_id" property="id"/><result column="items_id" property="itemsId"/><result column="items_num" property="itemsNum"/><result column="orders_id" property="ordersId"/></collection></resultMap> 

(3)映射的查询结果集中的列标签可以根据需要灵活变化,并且,在映射关系中,还可以通过typeHandler设置实现查询结果值的类型转换,比如布尔型与0/1的类型转换。

例如:

<resultMap type="hdu.terence.bean.Message" id="MessageResult"> <!--存放Dao值--><!--type是和数据库对应的bean类名Message--><id column="id" jdbcType="INTEGER"property=" id"/><!--主键标签--><result column="COMMAND" jdbcType="VARCHAR" property="command"/><result column="DESCRIPTION" jdbcType="VARCHAR" property="description"/><result column="CONTENT" jdbcType="VARCHAR" property="content"/></resultMap> <select id="queryMessageList" parameterType="hdu.terence.bean.Message" resultMap="MessageResult">SELECTID,COMMAND,DESCRIPTION,CONTENT FROM message WHERE 1=1    <if test="command!=null and!&quot;&quot;.equals(command.trim())">and COMMAND=#{command}</if><if test="description!=null and!&quot;&quot;.equals(description.trim())">and DESCRIPTION like '%' #{description} '%'</if> </select>

resultType

resultType 是一种“查询结果集---Bean对象”数据类型映射关系,使用resultType关系,即可使Bean对象接收查询结果集;见名知意,该方法是通过查询结果集中每条记录(属性)的数据类型和Bean对象的数据类型作映射,若两者都相同,则表示匹配成功,Bean可以接收到查询结果。

   但是本方法有局限性,要求Bean对象字段名和查询结果集的属性名相同(可以大小写不同,大小写不敏感)。因为这个局限性,可以省略调resultMap进行属性名映射。

    一般适用于pojo(简单对象)类型数据,简单的单表查询。

   以下是resultType的写法,将其值设置成对应的java类上即可。不需要上述resultMap的映射关系。

<select resultType="User" id="findAll">select *from user </select>
<select resultType="com.itxiaotong.pojo.User" id="findById" parameterType="int">select *from user where id = #{userId} </select>
<select resultType="com.itxiaotong.pojo.User" id="findByUsernameLike" parameterType="string">
<bind value="'%'+username+'%'" name="likeName"/>
select * from user where username like #{likeName} 
</select>
<select resultType="com.itxiaotong.pojo.User" id="findPage">select * from user limit #{param1},#{param2} </select><select resultType="com.itxiaotong.pojo.User" id="findPage1">select * from user limit #{startIndex},#{pageSize} </select>
<select resultType="User" id="findPage2" parameterType="PageQuery">select * from user limit #{startIndex},#{pageSize} </select>

其中parameterType="PageQuery"的类是,下列内容

PageQuery.java

package com.itxiaotong.pojo;public class PageQuery {private int startIndex;private int pageSize;public PageQuery() {}public PageQuery(int startIndex, int pageSize) {this.startIndex = startIndex;this.pageSize = pageSize;}public int getStartIndex() {return startIndex;}public void setStartIndex(int startIndex) {this.startIndex = startIndex;}public int getPageSize() {return pageSize;}public void setPageSize(int pageSize) {this.pageSize = pageSize;}
}
<select resultType="com.itxiaotong.pojo.User" id="findPage3" parameterType="map">select * from user limit #{startIndex},#{pageSize} </select><select resultType="int" id="findCount">select count(id) from user </select>

parameterType

在mybatis映射接口的配置中,有select,insert,update,delete等元素都提到了
parameterType的用法,parameterType为输入参数,在配置的时候,配置相应的
输入参数类型即可。parameterType有基本数据类型和复杂的数据类型配置。
1.基本数据类型,如输入参数只有一个,其数据类型可以是基本的数据类型,也可以是
自己定的类类型。包括int,String,Integer,Date,如下:

(1)根据id进行相应的删除:

(2)添加员工:

2.复杂数据类型:包含java实体类,map。


parameterType例子(一)

 现在有一个Mapper配置文件,以下是片段:

 <select id="queryCommandListByPage" resultMap="CommandResult" >select <include refid="columns"/> from command a left join command_content b on a.id=b.command_id<where><if test="command.name != null and !"".equals(command.name.trim())">and a.name=#{command.name}</if><if test="command.description != null and !"".equals(command.description.trim())">and a.description like '%' #{command.description} '%'</if></where><if test="flag==1">group by aid</if>order by id</select><sql  id="columns">a.id aid,a.name,a.description,b.content,b.id,b.command_id</sql>

下面是IService接口:

 /*** 拦截器实现分页*/public List<command> queryCommandListByPage(Map<String,Object>parameter);

parameterType例子(二)

<insert id="add" parameterType="com.itxiaotong.pojo.User">insert into user(username, sex, address)values (#{username}, #{sex}, #{address}) </insert>
<update id="update" parameterType="com.itxiaotong.pojo.User">update user set username = #{username},sex = #{sex},address=#{address} where id = #{id} </update>
<delete id="delete" parameterType="int">delete from user where id = #{id} </delete>
<insert id="add2" parameterType="com.itxiaotong.pojo.User"><!-- keyProperty:主键属性名 keyColumn:主键列名 resultType:主键类型 order:执行时机 --><selectKey resultType="int" order="AFTER" keyColumn="id" keyProperty="id">SELECT LAST_INSERT_ID(); </selectKey>
insert into user(username, sex, address)values (#{username}, #{sex}, #{address}) 
</insert>
<select resultType="com.itxiaotong.pojo.User" id="findPage3" parameterType="map">select * from user limit #{startIndex},#{pageSize} </select>

http://www.rdtb.cn/news/15906.html

相关文章:

  • 湛江专业的免费建站在线看crm系统
  • 斗鱼类的直播网站开发新乡网络推广外包
  • 企业网站建设性能分析百度推广开户怎么开
  • 律师网络推广哪个比较好合肥百度搜索排名优化
  • 建站专家网站建设系统南京seo收费
  • 哪个网站学做凉皮有做网站的吗
  • phpcms网站后台google关键词搜索量
  • 枣庄手机网站建设公司百度号码查询平台
  • 创意福州网站建设网站搭建需要多少钱
  • 服装移动网站策划案如何加入广告联盟赚钱
  • 连接国外网站做端口映射网络营销都有哪些形式
  • 好看的网站首页特效买友情链接有用吗
  • 阿里做网站seo值怎么提高
  • 做网站一般有什么题目北京seo顾问推推蛙
  • 陕西省建设厅网站安全员报名防晒霜营销软文
  • 做58推广网站找哪家好seo服务公司上海
  • 手机复制链接提取视频的软件西昌seo快速排名
  • 绿色主色调的网站周口seo推广
  • 河南住房和城乡建设部网站首页国内搜索引擎排行榜
  • 自助网站设计平台凯里seo排名优化
  • 用vue-cli做的网站搜索引擎优化的七个步骤
  • 小程序模板设计上海百度推广优化公司
  • 最快网站备案免费crm
  • 用阿里云做网站注意事项软文代写价格
  • 永丰县城乡建设局网站网络营销产品的首选产品
  • b2c网站优点青岛seo霸屏
  • 洛阳做多屏合一网站网站开发流程
  • 网站建设与推广外贸平台排名
  • 小说网站防盗做的好处seo关键词排名优化制作
  • 北京移动网站建设公司排名优化怎么做