Mysql hibernate delete查询从我的应用程序启动时不工作

Mysql hibernate delete查询从我的应用程序启动时不工作,mysql,hibernate,Mysql,Hibernate,当它从我的应用程序执行时,上述操作不起作用。我从这里得到的问题是 String query = DElETE from Photo where pId = :id and photoName = :name; getSession().createQuery(query).setParameter("id", id) .setParameter("name", name).executeUpdate(); 我甚至用过 createSQLQuery(从照片中删除,其中id=77,照片名称为'77

当它从我的应用程序执行时,上述操作不起作用。我从这里得到的问题是

String query = DElETE from Photo where pId = :id and photoName = :name;
getSession().createQuery(query).setParameter("id", id)
.setParameter("name", name).executeUpdate();
我甚至用过

createSQLQuery(从照片中删除,其中id=77,照片名称为'77 Hollywood Star.jpg';)

但是没有用


当我在mysql中运行这个程序时,上面的代码就起作用了

我假设上述代码是您用于测试目的的实际代码,我怀疑它们与您的参数名称不匹配,但不确定。请在这里发布您的异常详细信息


干杯

那么根据评论,我理解您只需要提交事务

请记住,hibernate是一个相当复杂的框架,如果您不使用实体管理器,您必须自己管理事务

干杯


LG

您刷新了会话并提交了事务吗?感谢LMG,提交后它工作正常。。。
delete from photo where id = 77 and photo_name = '77-Hollywood-Star.jpg';