介绍两种方法
1.Annotation设定@Column(updatable=false)
在不需要更新的属性上添加这个注解。这种方法不灵活,很少使用。
2.使用HQL
@Test
public void testUpdate4() {
Session session = sf.getCurrentSession();
session.beginTransaction();
Query q = session.createQuery("update Student s set s.name='jack' where s.id=1");
q.executeUpdate();
session.getTransaction().commit();
}