流程:model-->dao-->service-->impService-->action

如果只是操作单个的一个表,比如user表,则都写到user的流程中

如果要操作俩个表,+manage,就要用到 关联 了,这个时候操作起来还是对一个表,因为user表里面包含另一个表mange。

既然是面向对象,那么userModel-->userDAO-->userService-->userImpService-->userAction 等等一切的返回值都是user 或者是List<user>

但是遇到这样一个问题:

情况一:

    public List<Xmxx> findXmxxsByGksh(){
        String hql="from Xmxx where DM_ZT_GKSH = 2 ";
        return this.xmxxDAO.findList(hql);
    }

这个应该没有问题,this.xmxxDAO.findList(hql);返回的是List<Xmxx>

情况二:

    public List<Xmxx> findXmxxsByZt_sq(String USERNAME){
        String hql="from Xmxx x inner join x.yhxxs y where DM_ZT_TX in (0,1) and y.USERNAME=:USERNAME ";
        List<Xmxx> xmxxList=new ArrayList<Xmxx>();
        Map map=new HashMap();
        map.put("USERNAME", USERNAME);
        List list=this.yhxxDAO.findListOfMap(hql, map);
        if(list!=null){
            Iterator it=list.iterator();
            while(it.hasNext()){
                Object[] obj=(Object[])it.next();
                xmxxList.add((Xmxx)obj[0]);
            }
        }
        return xmxxList;
    }

注意看这里List list=this.yhxxDAO.findListOfMap(hql, map),这样写不会报错。

如果把yhxxDAO去掉,只写this.findListOfMap(hql,map)也不会报错。

但是List<Xmxx> list=this.yhxxDAO.findListOfMap(hql, map),就会出错,提示cannot convert from List<Yhxx> to List<Xmxx>。

 

相关文章:

  • 2022-01-27
  • 2021-07-24
  • 2021-12-14
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
猜你喜欢
  • 2021-09-12
  • 2021-07-11
  • 2021-09-20
  • 2021-09-28
  • 2022-12-23
  • 2022-03-03
相关资源
相似解决方案