账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    mybatis 参数传递
    37
    0

    用mybatis插入语句时报错: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类信息如下:

    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;
        }
    }
    
    
    1
    打赏
    收藏
    点击回答
        全部回答
    • 共 0 条
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部