zoukankan      html  css  js  c++  java
  • 【数据库_Postgresql】实体类映射问题之不执行sql语句

    后台controller到dao都没问题,前台页面接收的是一个实体类对象,在service层接收的也是对象,传入mapper里面的也是对象,没有用map,但是打印台却不执行sql语句,也没有明显错误提示。

    最后发现原因所在,贴出原来的sql语句和更改后成功执行的sql语句,可以看出别名和if test判断去除之后便可以执行。具体是因为别名还是if test有兴趣的朋友可以测试一下,我就不试了。

    原来的代码

    <select id="queryByPrimaryKey" parameterType="java.lang.String" resultType="com.suneee.scn.chtpub.wms.model.DictionaryDO">
             SELECT
                    dictionarycode as dictionarycode ,
                    dictionaryname as dictionaryname,
                    nextvalue as nextvalue ,
                    mark as mark
             FROM
                    sp_wms_dictionary 
             WHERE
                    1 = 1
    <if test="dictionarycode !=null  and dictionarycode != '' ">
                 AND dictionarycode = #{dictionarycode,jdbcType=VARCHAR}
            </if>
             
      </select>

    现在代码:

    <select id="queryByPrimaryKey" parameterType="java.lang.String" resultType="com.suneee.scn.chtpub.wms.model.DictionaryDO">
             SELECT
                    dictionarycode,
                    dictionaryname,
                    nextvalue,
                    mark
             FROM
                    sp_wms_dictionary 
             WHERE
                    1 = 1
             AND    dictionarycode = #{dictionarycode,jdbcType=VARCHAR}
             
      </select>
  • 相关阅读:
    基础语法 -实验楼
    JavaSE案例-Bank
    初识Java
    Java学习大纲-0412更新
    增量法
    蛮力法
    Host‘116.77.33.xx’is not allowed to connect to this MySQL server
    Maven坐标
    HotSpot虚拟机对象创建
    程序计数器为什么是线程私有的?
  • 原文地址:https://www.cnblogs.com/dflmg/p/6650621.html
Copyright © 2011-2022 走看看