NutzCN Logo
问答 updateWith 中使用过滤字段的问题
发布于 2054天前 作者 Zhouwt998 1594 次浏览 复制 上一个帖子 下一个帖子
标签:
FieldFilter.create(Fence.class,true)
                .set(FenceStudent.class,true)
                .set(FenceXYZ.class,true)
                .run(new Atom() {
                    @Override
                    public void run() {
                        fence.setUpdateTime(DateUtils.getCurrentTime());
                        // 坐标
                        List<FenceXYZ> fenceXYZs = Json.fromJsonAsList(FenceXYZ.class, fence.getFenceXYZ());
                        fence.setFenceXYZs(fenceXYZs);
                        // 学生
                        List<FenceStudent> fenceStudents = Json.fromJsonAsList(FenceStudent.class, fence.getStudentId());
                        fence.setFenceStudents(fenceStudents);
                        dao.updateWith(fence,null);
                    }
                });
18-11-27 15:35:02.718 DEBUG [XNIO-2 task-1] UPDATE ic_fence SET fence_name=?,fence_describe=?,fence_alarm=?,alarm_type=?,alarm_start=?,alarm_end=?,update_time=?  WHERE id=?
    |    1 |      2 | 3 | 4 |                   5 |                   6 |                   7 | 8 |
    |------|--------|---|---|---------------------|---------------------|---------------------|---|
    | 更新测试 | 更新测试描述 | 0 | 0 | 1970-01-01 12:00:00 | 1970-01-01 16:00:00 | 2018-11-27 15:35:02 | 6 |
  For example:> "UPDATE ic_fence SET fence_name='更新测试',fence_describe='更新测试描述',fence_alarm=0,alarm_type=0,alarm_start='1970-01-01 12:00:00',alarm_end='1970-01-01 16:00:00',update_time='2018-11-27 15:35:02'  WHERE id=6"
18-11-27 15:35:02.724 DEBUG [XNIO-2 task-1] UPDATE ic_fence_student SET student_id=?  WHERE id=?
    |      1 |    2 |
    |--------|------|
    | xm5555 | NULL |
    | xm4    | NULL |
  For example:> "UPDATE ic_fence_student SET student_id='xm5555'  WHERE id=NULL"
18-11-27 15:35:02.725 DEBUG [XNIO-2 task-1] UPDATE ic_fence_XYZ SET latitude=?,longitude=?  WHERE id=?
    |     1 |     2 |    3 |
    |-------|-------|------|
    | 1.1.1 | 1.1.1 | NULL |
    | 2.0.0 | 2.0.2 | NULL |
    | 3.0.0 | 3.0.3 | NULL |
  For example:> "UPDATE ic_fence_XYZ SET latitude='1.1.1',longitude='1.1.1'  WHERE id=NULL"

在更新被映射的实体时,where id 为什么是null,这样就无法更新了,是我的用法有问题吗

5 回复
List<FenceStudent> fenceStudents = Json.fromJsonAsList(FenceStudent.class, fence.getStudentId());

这是啥操作...

fence.getStudentId()等于[{"studentId":"xm5555"},{"studentId":"xm4"}],我就是转换成实体

哦哦,id确实没有设置,那岂不是还要循环设置一下值才行。。。

添加回复
请先登陆
回到顶部