mybatis+mysql问题

在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中创建该属性。我该怎么办?

作者: chongchongyehenmao   发布时间: 2011-05-30

打印出你的sql

作者: rucypli   发布时间: 2011-05-30

引用 1 楼 rucypli 的回复:
打印出你的sql


insert into t_dept(<include refid="deptColumn"/>)
values(<include refid="deptValue"/>)
就是这个啊。

作者: chongchongyehenmao   发布时间: 2011-05-30