mybatis+mysql问题
时间:2011-05-30
来源:互联网
在sql语句中为了实现inset允许插入空字段,我用了下面的方法,但是报错。
<sql id="deptValue">
<trim suffix="" suffixOverrides=",">
<if test="deptName != null and deptName != '' ">
#{deptName},
</if>
<if test="keyinId != null and keyinId != '' ">
#{keyinId},
</if>
<if test="deptTel != null and deptTel != '' ">
#{deptTel},
</if>
<if test="supervisorId != null and supervisorId != '' ">
#{supervisorId},
</if>
<if test="contactId != null and contactId != '' ">
#{contactId},
</if>
<if test="deptNote != null and deptNote != '' ">
#{deptNote},
</if>
<if test="deptFatherId != null and deptFatherId != '' ">
#{deptFatherId},
</if>
</trim>
</sql>
<sql id="deptColumn">
<trim suffix="" suffixOverrides=",">
<if test="vc_dept_name != null and vc_dept_name != '' ">
vc_dept_name,
</if>
<if test="n_keyin_id != null and n_keyin_id != '' ">
n_keyin_id,
</if>
<if test="vc_dept_tel != null and vc_dept_tel != '' ">
vc_dept_tel,
</if>
<if test="n_dept_supervisor_id != null and n_dept_supervisor_id != '' ">
n_dept_supervisor_id,
</if>
<if test="n_dept_contact_id != null and n_dept_contact_id != '' ">
n_dept_contact_id,
</if>
<if test="vc_note != null and vc_note != '' ">
vc_note,
</if>
<if test="n_dept_father_id != null and n_dept_father_id != '' ">
n_dept_father_id,
</if>
</trim>
</sql>
<insert id="InsertDept" parameterType="dept">
insert into t_dept(<include refid="deptColumn"/>)
values(<include refid="deptValue"/>)
</insert>
报错:There is no getter for property named 'vc_dept_name' in 'class com.leidun.rights.model.Dept'
当我在com.leidun.rights.model.Dept类中创建相应的vc_dept_name,就不报错了。但是这个是我的表字段名,我不想在Dept中创建该属性。我该怎么办?
<sql id="deptValue">
<trim suffix="" suffixOverrides=",">
<if test="deptName != null and deptName != '' ">
#{deptName},
</if>
<if test="keyinId != null and keyinId != '' ">
#{keyinId},
</if>
<if test="deptTel != null and deptTel != '' ">
#{deptTel},
</if>
<if test="supervisorId != null and supervisorId != '' ">
#{supervisorId},
</if>
<if test="contactId != null and contactId != '' ">
#{contactId},
</if>
<if test="deptNote != null and deptNote != '' ">
#{deptNote},
</if>
<if test="deptFatherId != null and deptFatherId != '' ">
#{deptFatherId},
</if>
</trim>
</sql>
<sql id="deptColumn">
<trim suffix="" suffixOverrides=",">
<if test="vc_dept_name != null and vc_dept_name != '' ">
vc_dept_name,
</if>
<if test="n_keyin_id != null and n_keyin_id != '' ">
n_keyin_id,
</if>
<if test="vc_dept_tel != null and vc_dept_tel != '' ">
vc_dept_tel,
</if>
<if test="n_dept_supervisor_id != null and n_dept_supervisor_id != '' ">
n_dept_supervisor_id,
</if>
<if test="n_dept_contact_id != null and n_dept_contact_id != '' ">
n_dept_contact_id,
</if>
<if test="vc_note != null and vc_note != '' ">
vc_note,
</if>
<if test="n_dept_father_id != null and n_dept_father_id != '' ">
n_dept_father_id,
</if>
</trim>
</sql>
<insert id="InsertDept" parameterType="dept">
insert into t_dept(<include refid="deptColumn"/>)
values(<include refid="deptValue"/>)
</insert>
报错:There is no getter for property named 'vc_dept_name' in 'class com.leidun.rights.model.Dept'
当我在com.leidun.rights.model.Dept类中创建相应的vc_dept_name,就不报错了。但是这个是我的表字段名,我不想在Dept中创建该属性。我该怎么办?
作者: chongchongyehenmao 发布时间: 2011-05-30
打印出你的sql
作者: rucypli 发布时间: 2011-05-30
引用 1 楼 rucypli 的回复:
打印出你的sql
打印出你的sql
insert into t_dept(<include refid="deptColumn"/>)
values(<include refid="deptValue"/>)
就是这个啊。
作者: chongchongyehenmao 发布时间: 2011-05-30
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28