public void increase(int i){
Query query=factory.getCurrentSession().createQuery("UPDATE Champ c set c.idChamp=c.idChamp+1 WHERE c.idChamp>= :var ORDER BY DESC");
query.setParameter("var",i+1);
int result=query.executeUpdate();
System.out.println(result);
}
我也试过这个
@SuppressWarnings("unchecked")
public void increase(int i){
String hql = "from Champ c WHERE c.idChamp>=:num ORDER BY DESC";
List<Champ> lesChamps = ( factory.getCurrentSession().createQuery(hql)
.setParameter("num", i)).list();
for (Champ c: lesChamps){
c.setIdChamp(c.getIdChamp()+1);
}
}