@Transactional
@Modifying
public boolean deleteBook(String callno, String studentid) {
boolean userFounds= false;
Session session=this.sessionFactory.openSession();
System.out.println("check update:"+callno);
System.out.println("check update:"+studentid);
// delete operation
String SQL_QUERY2 ="delete from IssueBook where callno= ? and studentid=?";
Query query= session.createQuery(SQL_QUERY2);
query.setParameter(0, callno).executeUpdate();
query.setParameter(1, studentid).executeUpdate();
return userFounds;
}
我收到500台服务器的异常 在这 query.setParameter(0,callno).executeUpdate(); query.setParameter(1,studentid).executeUpdate();
查看堆栈跟踪:
答案 0 :(得分:0)
String SQL_QUERY2 ="delete from IssueBook where callno=:callno and studentid=:studentid";
Query query= session.createQuery(SQL_QUERY2);
query.setParameter(callno, callno);
query.setParameter(studentid, studentid);
return query.executeUpdate();
代码中的问题是executeUpdate(),应在设置所有参数后调用一次。