Closed GoogleCodeExporter closed 9 years ago
按照那些出错信息, 输入值为空字符串,不是null哦.
Original comment by wendal1985@gmail.com
on 5 Jan 2010 at 2:50
是的,我在jsp页面放了<input type="hidden" name="createtime"/>
Original comment by gdun...@gmail.com
on 6 Jan 2010 at 1:53
恩, 如何处理好呢? 空字符串忽略掉? 不太好吧...
既然你不传值, 那干脆去掉<input type="hidden"
name="createtime"/>不就可以了?
Original comment by wendal1985@gmail.com
on 6 Jan 2010 at 2:07
目前是这样处理的,如果将createtime去掉,在update时,就需要�
��以下的方式更新,因为
creatime是not null的。
final User u = user;
FieldFilter.create(User.class, true).run(new Atom() {
public void run() {
users.dao().update(u);
}
});
觉得有点啰嗦,你觉得呢?
Original comment by gdun...@gmail.com
on 6 Jan 2010 at 2:33
按照你的描述,createTime是系统自动创建的
意思是你自己的代码set进去,还是数据库帮你set进去?
Original comment by wendal1985@gmail.com
on 6 Jan 2010 at 2:38
所以,我们需要修改 update 的默认行为
当字段为 null 时不更新,除非显示的通过
FieldFilter.create(User.class, false).run(new Atom() {
public void run() {
users.dao().update(u);
}
});
或者在 Dao 接口增加一个函数 update(T obj, boolean ignoreNullField);
Original comment by zozoh...@gmail.com
on 6 Jan 2010 at 8:03
Fixed in 1.a.26(r811)
增加了 Dao 接口函数 updateIgnoreNull(T obj)
Original comment by zozoh...@gmail.com
on 12 Jan 2010 at 8:01
Original comment by wendal1985@gmail.com
on 13 May 2010 at 11:00
Verified in 1.a.28
Original comment by wendal1985@gmail.com
on 15 May 2010 at 8:29
Original issue reported on code.google.com by
gdun...@gmail.com
on 5 Jan 2010 at 10:34