1 | <property name=”age” update=” false ”></property><BR> |
在Annotation中 在属性GET方法上加上@Column(updatable=false)
2.第2种方法··使用XML中的 dynamic-update="true"
1 | < class name= "com.sccin.entity.Student" table= "student" dynamic-update= "true" /><BR> |
OK,这样就不需要在字段上设置了。
但这样的方法在Annotation中没有
使用HQL语句修改数据
Query query = session.createQuery(
"update Teacher t set t.name = 'yangtianb' where id = 3"
)