码迷,mamicode.com
首页 > 其他好文 > 详细

Room多表查询不能嵌套

时间:2019-11-27 13:49:14      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:data   多表查询   val   sub   text   omd   col   select   list   

WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getFailProjDao().getFailedProjects().observe(TrainFragment.this, new Observer<List<FailedProj_select>>() {
            @Override
            public void onChanged(List<FailedProj_select> failedProj_selects) {
                for (FailedProj_select f :
                        failedProj_selects) {
                    item_id += f.getScore_deducting();
                    Log.i(TAG, "onChanged: "+f.toString());
                    Toast.makeText(getActivity().getApplicationContext(),"得分"+item_id,Toast.LENGTH_SHORT).show();
                }

            }
        });

像这种的会重复查多次

 

正确的写法如下:两段代码平行分开不能嵌套

  WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getFailProjDao().getSubject(1).observe(this, new Observer<Integer>() {
            @Override
            public void onChanged(Integer integers) {
                Log.i(TAG, "onChanged: "+integers.intValue());
                item_id = 0;


            }
        });      
        WorkRoomDataBase.getWorkRoomDataBase(getContext().getApplicationContext()).getFailProjDao().getFailedProjects().observe(TrainFragment.this, new Observer<List<FailedProj_select>>() {
            @Override
            public void onChanged(List<FailedProj_select> failedProj_selects) {
                for (FailedProj_select f :
                        failedProj_selects) {
                    item_id += f.getScore_deducting();
                    Log.i(TAG, "onChanged: "+f.toString());
                    Toast.makeText(getActivity().getApplicationContext(),"得分"+item_id,Toast.LENGTH_SHORT).show();
                }

            }
        });

  

Room多表查询不能嵌套

标签:data   多表查询   val   sub   text   omd   col   select   list   

原文地址:https://www.cnblogs.com/endian11/p/11941651.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!