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

东莞快速做网站怎样做废旧网站

东莞快速做网站,怎样做废旧网站,做博客网站需要工具吗,河北燕郊网站制作40_resultMap基础和Results注解 resultType和resultMap<resultMap.../>元素项目0501resultMap Results注解项目0502resultMap注解&#xff08;Results) 【总结】 resultType和resultMap resultType指定结果集每条记录要映射的对象类型。resultMap表明使用自定义的映射规…

40_resultMap基础和@Results注解

  • resultType和resultMap
    • <resultMap.../>元素
      • 项目0501resultMap
    • @Results注解
      • 项目0502resultMap注解(@Results)
    • 【总结】

resultType和resultMap

  • resultType指定结果集每条记录要映射的对象类型。
  • resultMap表明使用自定义的映射规则,resultMap属性值为一个<resultMap…/>元素的id属性值
      resultMap比指定resultType要稍微复杂一些,但它的功能更强大

<resultMap…/>元素

resultMap专门定义一个映射规则:完成结果集与Java对象之间的映射关系
必须指定如下属性:
- id:指定该<resultMap…/>的唯一标识。
- type:指定该<resultMap…/>映射的Java对象的类型。

<resultMap…/>的两个常用子元素:<id…/>和<result…/>,
<id…/>元素映射标识属性列,<result…/>映射普通列
它们都可指定以下属性:
- column:指定列名。
- property:指定对应的属性名。
- javaType:指定属性的Java类型。一般无需指定,MyBatis可以自动推断。
- jdbcType:指定该列的JDBC类型。一般无需指定,MyBatis可以自动推断。
- typeHandler:为该数据列与属性值之间的转换指定类型处理器。

项目0501resultMap

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 根元素是mapper,该元素的namespace属性值相当于该mapper的唯一标识 -->	
<mapper namespace="org.itcheng.app.dao.NewsMapper"><!-- SQL的id需要与Mapper接口的方法名相同  --><insert id="saveNews">insert into news_inf values (null, #{title}, #{content})</insert><!-- 定义SQL语句 --><update id="updateNews">update news_inf set news_title = #{title}, news_content = #{content}where news_id=#{id}</update><!-- SQL的id需要与Mapper接口的方法名相同  --><delete id="deleteNews">delete from news_inf where news_id = #{xyz} </delete><!-- 使用resultMap来完成结果集与Java对象之间的映射关系--><select id="findNews" resultMap="newsMap">select * from news_inf where news_id > #{id}		</select><!-- resultMap专门定义一个映射规则:完成结果集与Java对象之间的映射关系 --><resultMap type="news" id="newsMap" ><id column="news_id" property="id" /><!-- 映射映射标识属性 数据库的表字段news_id对应news对象的 id属性 --><result column="news_title" property="title"/><!-- 映射映射普通属性 --><result column="news_content" property="content"/><!-- 映射映射普通属性 --></resultMap></mapper>

@Results注解

<resultMap…/>元素对应于@Results注解
该注解的value属性可指定多个@Result注解
@Result相当于 <id…/>和<result…/>的综合体,当它的id属性为true,代表<id…/>元素。

项目0502resultMap注解(@Results)

package org.itcheng.app.dao;import java.util.List;import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.itcheng.app.domain.News;// Mapper组件相当于DAO组件
public interface NewsMapper
{@Insert("insert into news_inf values (null, #{title}, #{content})")int saveNews(News news);@Update("update news_inf set news_title = #{title}, news_content = #{content}\r\n" + "where news_id=#{id}")int updateNews(News news);@Delete("delete from news_inf where news_id = #{xyz}")void deleteNews(Integer id);@Select("select * from news_inf where news_id > #{id}")@Results({// id = "true"相当于<id.../>子元素@Result(column = "news_id", property = "id", id = true),//表字段news_id对应news对象的 id属性@Result(column = "news_title", property = "title"),@Result(column = "news_content", property = "content")})List<News> findNews(Integer id);}

【总结】

<resultMap…/>等同于@Results注解
<id…/>或 <result …/>等同于@Result注解

http://www.yayakq.cn/news/608669/

相关文章:

  • 汕头市通信建设管理局网站企业首次建设网站方案流程
  • 成都教育行业网站建设怎么制作公众号推送
  • 网监备案网站wordpress站群管理
  • 网站图标用代码代替电商平台网站多少钱
  • 做游戏网站赚钱吗网站后台如何修改文字
  • 公司部门部长是什么级别对网站进行优化
  • 网站到期时间适合网站开发的python
  • 宣传旅游网站建设的观点是什么网站开发的报告
  • 建站公司如何在抖音平台开店创业ppt模板免费
  • 网站建设绿茶科技中国商网
  • 自贡做网站的公司网站建设预算表格
  • 韩国家具网站模板tp框架网站开发参考文献
  • 网站备案密码重置做网站公众号要多少钱
  • 如何更改网站标签logo网络营销的五大特点
  • 特色的南昌网站建设vs2017手机网站开发
  • asp手机网站源码免费心理咨询
  • 极简资讯网站开发广州网站优化推广公司
  • 软件app网站建设python编程软件安装教程
  • 昆明网站的优化敬请期待英文翻译
  • 网站建设公司哪有做360手机网站快速排
  • 河北省建设项目信息网站浙江省建设信息港三类人员证书查询
  • 汽车网站开发与实现 论文怎么建自己公司网站
  • 电子商务成功网站的案例深圳做网站要多少
  • seo快速排名软件网站网站开发视频是存储的
  • 哪个网站免费建站最好四川省建设岗位注册中心网站
  • 重庆荣昌网站建设淄博网站建设给力臻动传媒
  • 室内设计师联盟网站怎么做培训班网站
  • 有哪些可以做课件赚钱的网站网站底部设计代码
  • 网站开发好公司程序源代码下载网站
  • 印尼做网站的教学 中文河北关键词搜索排名公司