在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Java/ mybatis 參數(shù)傳遞

mybatis 參數(shù)傳遞

用mybatis插入語(yǔ)句時(shí)報(bào)錯(cuò):There is no getter for property named 'DictionaryType' in 'class com.bjpowernode.crm.domain.DictionaryType'

代碼如下:

public int insertDictionaryType(DictionaryType dictionaryType) {
    SqlSessionFactory sqlSessionFactory = null;
    SqlSession sqlSession = null;
    int num = 0;
    try {
        sqlSessionFactory = new SqlSessionFactoryBuilder()
                .build(Resources.getResourceAsStream("mybatis-config.xml"));
        sqlSession = sqlSessionFactory.openSession();
        dictionaryType.setCode(UUIDGenerator.generate());
        num = sqlSession.insert("insertDictionaryType", dictionaryType);

        sqlSession.commit();
    } catch (IOException e) {
        if (sqlSession != null) {
            sqlSession.rollback();
        }
    } finally {
        if (sqlSession != null) {
            sqlSession.close();
        }
    }
    return num;
}

mapper.xml配置如下:

<mapper namespace="com.bjpowernode.crm.domain">
    <insert id="insertDictionaryType" parameterType="DictionaryType">
        insert into 
            tbl_dic_type
        values
            (#{DictionaryType.code},#{DictionaryType.name},#{DictionaryType.description})
        
    </insert>
</mapper>

DictionaryType類(lèi)信息如下:

public class DictionaryType {
    private String code;
    private String name;
    private String description;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
}

回答
編輯回答
忠妾

xml的insert語(yǔ)句去掉前面的DictionaryType即可

2017年2月28日 04:38