zoukankan      html  css  js  c++  java
  • mybatis相关记录

    1 字符串与时间戳的比较
       <![CDATA[and aa.INSERTTIME>=to_date(#{condition.joinStartTime},'yyyy-mm-dd')]]>

    2 mybatis oracle恶心批量插入方法,oracle id int nextval
      insert into tbname (NAME)  
       select tbname.NEXTVAL,aa.* from(
          <foreach collection="list" item="item" index="index" open="(" separator="union all" close=")">
        select #{item.name,jdbcType=VARCHAR} from DUAL
          </foreach>
        )aa
    3 传入多个参数时,parameterType作为map,collection则写list变量名
      int sce(@Param("gp") GP gp, @Param("id") Integer id);
      <select id="sce" resultType="java.lang.String"  parameterType="map" >
     select name from JSCNGAME.G_A_GROUP where name in
     <foreach collection="gp" item="item" index="index" open="(" separator="," close=")">
      #{item,jdbcType=VARCHAR}
     </foreach>
     <if test="id!=null">
      and id!=#{id,jdbcType=INTEGER}
     </if>
      </select>

    4 插入新记录的同时返回id值

       插入的同时返回id值
      <insert id="insert" parameterType="" >
        <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.Long">
         select id.nextval  as id  from  DUAL
     </selectKey>
        insert into tb(id) values (#{id})
      </insert>
      插入的同时不会返回id值
      <insert id="insert" parameterType="com.jscn.game.dmo.res.GResAnswer" >
        insert into tb(RESID) values (id.nextval)
      </insert>

    5 #和$区别及预编译

    mybatis #在入参两边加上双引号,作为字符串,$则原样显示,#可以起到过滤的sql注入功能,<![CDATA[]]>也会导致注入
    Preparstatment 使用?代替入参,预编译的sql语句在oracle看来是固定的,预编译sql就会类似于函数,直接使用,无需编译,效率提高,存储于缓存

    http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • 相关阅读:
    对弈类游戏的人工智能(5)--2048游戏AI的解读
    对弈类游戏的人工智能(4)--游戏AI的落地
    对弈类游戏的人工智能(3)--博弈树优化
    对弈类游戏的人工智能(2)--学习算法
    java.awt.headless 模式
    SpringBoot启动过程分析
    SpringBoot入门之内嵌Tomcat配置
    git tag的用法
    SpringBoot程序远程debug
    SpringBoot入门之分散配置
  • 原文地址:https://www.cnblogs.com/ai464068163/p/3022387.html
Copyright © 2011-2022 走看看