zoukankan      html  css  js  c++  java
  • sql,mybatis中Boolean类型 False无效问题

    mybatis中当查询条件有Boolean类型的时候,为false时查询无效

    eg:
    <if test="isOk != null and isOk !=''">
    and is_ok = #{isOk}
    </if>

    此时当isOk为false时,并未查询出is_ok对应的结果来

    找原因:
      直接到数据库使用脚本查询

     select * from table where is_ok = false

      此时能查出is_ok为0的数据

    select * from table where is_ok = true

      此时能查出is_ok为1的数据
      此时定位问题是否在

    此时能查出is_ok为0的数据

    <if test="isOk != null and isOk !=''">


      通过排查去掉and isOk!=’’,可以正确的查出

      所以正确的查询结构是:

    <if test="isOk != null">
        and is_ok = #{isOk}
      </if>

    经研究:
    mybatis的if判断里面最好不要使用boolean值:
    mybatis会默认把空值转为false。所以如果遇见前面传空值,这个字段在mybatis里面永远就是false了,可以使用数字类型代替,但是不要使用0作为参数。



    druid数据库解密加密

    import com.alibaba.druid.filter.config.ConfigTools;

    语句:

    @Test
    public void test2() throws Exception{
      //解密
      String word="NaSb06jVxVBGcmMeuv3wiRH6oiMLFVA0bRs6stSSz2m52pLJLne2uYQNZgIHJHfKn+TaPPw/lqVCpv2ylCaE9w==";
      String decryptword = ConfigTools.decrypt(word);
      System.out.println("++++++");
      System.out.println(decryptword);
    }
    @Test
    public void testEncrypt() throws Exception
    {
      //加密
      String password ="xxxxxxx";
      String encryptword = ConfigTools.encrypt(password);
      System.out.println(encryptword);
    }

    点点滴滴积累!

  • 相关阅读:
    AC 自动机
    [P4735] 最大异或和
    [HNOI2006] 最短母串问题
    [SHOI2002] 取石子游戏
    [NOI2014] 动物园
    [BZOJ2839] 集合计数
    【Spark】object not serializable (class: A)
    【Hbase】Master startup cannot progress, in holding-pattern until region onlined.
    Hbase 各个角色的工作。
    hbase region均衡机制
  • 原文地址:https://www.cnblogs.com/zq-ding/p/11634418.html
Copyright © 2011-2022 走看看