
正文
【数据库_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>







