码迷,mamicode.com
首页 > 数据库 > 详细

【数据库_Postgresql】实体类映射问题之不执行sql语句

时间:2017-03-31 13:19:46      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:class   type   lan   sql语句   and   rom   后台   ice   dict   

后台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>

 

【数据库_Postgresql】实体类映射问题之不执行sql语句

标签:class   type   lan   sql语句   and   rom   后台   ice   dict   

原文地址:http://www.cnblogs.com/dflmg/p/6650621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!