hibernate createQuery查询传递参数的两种方式
String hql = "from InventoryTask it where it.orgId=:orgId";
        Session session = getSession();
        Query query=session.createQuery(hql);
        query.setString("orgId",orgId);
        List list = query.list();
        if(list!=null&&list.size()!=0){
            return (InventoryTask)list.get(0);
        }else{
            return null;
        }
hibernate createQuery查询传递参数的两种方式

方式二:

String hql = "from InventoryTask it where it.orgId=?,it.orgName=?";
        Session session = getSession();
        Query query=session.createQuery(hql);
        query.setString("0",orgId);
                query.setString(1,orgName)
        List list = query.list();
        if(list!=null&&list.size()!=0){
            return (InventoryTask)list.get(0);
        }else{
            return null;
        }

 

相关文章:

  • 2022-12-23
  • 2022-03-06
  • 2022-01-29
  • 2022-01-01
  • 2021-09-05
  • 2021-09-05
  • 2021-09-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
  • 2022-02-07
  • 2021-05-31
相关资源
相似解决方案