查询数据系列问题
使用过的查询方法-
fetchDate
JsonObject fetchData = detailS.fetchData(DetailDao, Detail.class,
new CustomFormatRow<Detail>() {
@Override
public void formatRow(Detail detail, SearchRow row) {}
}
fetchList
List<Proplan> proplanlist = proplanS.fetchList(proplanDao, Proplan.class);
Proplan proplan = null;
if(proplanlist!=null && proplanlist.size()==1) {
proplan = proplanlist.get(0);
}
if(proplan!=null) {
}
findOne
for (int i = 0; i < selectRows.size(); i++) {
DxRecord dxRecord2 = dxRecordDao.findOne(selectRows.get(i));
}
CoatingPlan paintingPlan = planService.findOne(dxDetail.getProplanid());
DxDetail undetail = dxuncoilDao.findOne(t.getDxdetailid());
自定义方法
@Query(value="SELECT beizhu FROM upcoiler WHERE gunum = ?1 LIMIT 1 ",nativeQuery=true)
String getSxsjrecord(String rzgunum);
String sxsjbeizhu = sxproductDetailDao.getSxsjrecord(detail.getRzgunum());
row.add("sxsjrecord", sxsjbeizhu);
public DxRecord findByGunum(String gunum) {
return dxDao.findByGunum(gunum);
DxRecord dxRecord = dxRecordService.findByGunum(t.getDxgunum());
在lygz报表中出现的问题
- 在进行从
plan
里筛选数据时,第一次写的是用findOne(id)
进行数据查询,但是plan
里边的id
对应的是生产明细中的proplanid
,而findOne()
这个方法是要通过主键进行筛选,很显然这里不能调用findOne()
方法。
解决方式
- 由于所出现的问题,所以在
lygz
报表中调用了查询类的fetchList
方法来取出相对应的数据。
- PS: 也可以通过
Dao
层的查询语句来进行数据的获取,要注意在Dao
里拼写Sql
语句过多会影响数据的查询速度。
fetchDate
返回的数据为JSON
格式。
拓展