Hibernate提供有save().persist().savaOrUpdate()和merge()等方法来提供插入数据的功能.前三者理解起来较后者容易一些,而merge()方法从api中的介绍就可以看出它是最复杂的,因此要特别留意一下. Hibernate的api中关于merge()方法的原文 merge Object merge(Object object) throws HibernateException Copy the state of the given object onto…
虽然hibernate提供了许多方法对数据库进行更新,但是这的确不能满足开发需要.现在讲解一下用hql语句对数据进行更新. 不使用参数绑定格式String hql="update User u set u.userName=123 where u.userId=2"; 介绍5种参数绑定,和为什么要使用参数绑定,好处在哪里. 一.query.setParameter(属性名,真实值,类型); String hql="update User u set u.userName=:u…