不起作用
String sql = "UPDATE xsp_job_request SET xsp_job_status_id = 2 , xsp_job_id = :xspJobId WHERE xsp_job_request_id = :xspJobRequestId AND xsp_job_status_id = 1";
Query query = entityManager.createNativeQuery(sql);
query.setParameter("xspJobId", jobId);
query.setParameter("xspJobRequestId", jobRequestId);
affectedRows = query.executeUpdate();
正在工作。但是需要使用namedParameter参数查询
String sql = "UPDATE xsp_job_request SET xsp_job_status_id = 2 , xsp_job_id = '7884ed98-972a-46c8-ae22-e4f445b4568' WHERE xsp_job_request_id = '8fa2c5e46638ad66016638adab060000' AND xsp_job_status_id = 1";
Query query = entityManager.createNativeQuery(sql);
affectedRows = query.executeUpdate();
答案 0 :(得分:0)
您必须将分配符号用作:=
冒号,并且两者之间不能有空格。
String sql = "UPDATE xsp_job_request SET xsp_job_status_id = 2, xsp_job_id =:xspJobId WHERE xsp_job_request_id =:xspJobRequestId AND xsp_job_status_id = 1";