JPA+HIBERNATE 执行非查询语句报 Update/delete queries cannot be typed JPAHIBERNATE
程序员文章站
2022-07-16 18:30:52
...
java.lang.IllegalArgumentException:Update/delete queries cannot be typed
一:错误写法
String hql = " delete from T_ST_CircuitMeterInfo e where e.circuitID = ?";
Query query = em.createQuery(hql, T_ST_CircuitMeterInfo.class);
query.setParameter(1, circuitID);
int count = query.executeUpdate();
二:正解
String hql = " delete from T_ST_CircuitMeterInfo e where e.circuitID = ?";
Query query = em.createQuery(hql);
query.setParameter(1, circuitID);
int count = query.executeUpdate();
delete语句执行createQuery的时候,不能传对象类。
上一篇: JPA 各种基本用法
下一篇: jquery datatable 参数