当前位置: 首页 > 知识库问答 >
问题:

如何修复线程“main”org.hibernate.Exception.sqlgrammareXception中的异常:无法执行本机大容量操作查询?

傅长恨
2023-03-14
int nr = nrfromPar; //13
int nrdays = nrfromPar;//1
Date data = datafromPar; //Thu May 11 23:11:09 EEST 2017

String statusRequest = "UPDATE home "
         + "SET date_ma = :data, nr_days_ma = :nrdays "
         + "WHERE nr_req = :nr";

SQLQuery simpleSQL = session.createSQLQuery(statusRequest );
    simpleSQL.setParameter("data", data);
    simpleSQL.setParameter("nrdays", nrdays);
    simpleSQL.setParameter("nr", nr);
 int a =simpleSQL.executeUpdate();
 System.out.println(a);
Hibernate: 
    UPDATE
        home
    SET
        date_ma = ?,
        nr_days_ma = ? 
    WHERE
        nr_req= ?
1

共有1个答案

林鸿彩
2023-03-14

未为参数%1指定值

您得到此错误,因为您没有为:data、:nrdays、:nr指定值,它应该如下所示:

SQLQuery simpleSQL = session.createSQLQuery(statusRequest );
simpleSQL.setParameter("data", some_value);
simpleSQL.setParameter("nrdays", some_value);
simpleSQL.setParameter("nr", some_value);

像这样使用:

String statusRequest = "UPDATE home "
         + "SET date_ma = ?, nr_days_ma = ? "
         + "WHERE nr_req = ?";
SQLQuery simpleSQL = session.createSQLQuery(statusRequest );
simpleSQL.setParameter(1, some_value);
simpleSQL.setParameter(2, some_value);
simpleSQL.setParameter(3, some_value);
 类似资料: