鍍金池/ 問答/Java  數(shù)據(jù)庫  網(wǎng)絡(luò)安全/ mybatis #{}問題求解

mybatis #{}問題求解

JavaWeb項目中寫的一條插入語句,大概是這樣

customerInfo對象中的值全有,不存在為空。

下面是添加方法

public boolean customerInfoAdd(SendCard customerInfo){
        try {
            sqlSession.insert("insertSendCard", customerInfo);
        } catch (Exception e) {
            log.error("添加出錯:insertSendCard");
            e.printStackTrace();
            return false;
        }
        return true;
    }
<insert id="insertSendCard"  parameterType="com.****.****.****.****">
     <![CDATA[ 
             insert into  T_SENDCARD(
               sendcardid,
               termid,
               idno,
              name,
              telphone,
              address,
              cardno,
              issuedate,
              operator,
              sex,
              nationality,
              birthday,
              cardtype,
              organs
              )
             values
             (
               #{sendcardid},
               #{termno},
              #{idcard_no},
              #{cus_name},
              #{phone},
              #{home_address},
              #{bankcardno},
              #{status_datetime},
              #{bankuserid},
              #{sex},
              #{nation},
              #{birthday},
              #{cardtype},
              #{fzjg}
             )
        ]]>    
     </insert>

插入數(shù)據(jù)失敗。

[0410 11:07:27 424 INFO ] [http-bio-8080-exec-7] factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[0410 11:07:27 451 INFO ] [http-bio-8080-exec-7] jdbc.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
[0410 11:07:27 456 ERROR] [http-bio-8080-exec-7] TradeLogDaoImpl - 添加出錯:insertSendCard
回答
編輯回答
冷眸

你的mapper接口怎么寫的

2018年6月9日 12:06
編輯回答
魚梓

在配置里吧mybatis設(shè)置為debug,然后執(zhí)行就能看到sql語句了,這樣方便你解決問題

2018年8月3日 14:33
編輯回答
撿肥皂

把parameterType寫具體一點試試,具體到SendCard,報錯信息放上來就好了

2018年4月29日 05:13
編輯回答
陪她鬧

給下Mapper接口、實體類就可以幫你解決來,現(xiàn)在信息太少,無法定位啊老鐵

2017年11月19日 11:05