Iam试图在藏书会上抽样收集学生信息。 就此,学生名称、阶级、教师。
表:统计
SNO SNAME SCLASS TNO
----------- ----------------------------------------
1 J D Alex 3 1
2 Goaty 2 2
3 J D Paul 7 1
法典:
Transaction tx1=session1.beginTransaction();
Object o2=session1.get(Student.class,new Integer(3));
((Student)o2).setSclass("8");
session1.save(o2);
log.info("loadStdYearlyInfo:class "+((Student)o2).getSclass());
tx1.commit();
session1.close();
After saving the data and seen the output the class value is updated as 8 for student id is 3
SNO SNAME SCLASS TNO
----------- ----------------------------------------
1 J D Alex 3 1
2 Goaty 2 2
3 J D Paul 8 1
[07/May/2012:10:03:06] info ( 3500): CORE3282: stdout: Hibernate: /* load com.aims.beans.Student */ select student0_.sno as sno0_, student0_.sname as sname1_0_, student0_.sclass as sclass1_0_, student0_.tno as tno1_0_ from student student0_ where student0_.sno=?
[07/May/2012:10:03:06] info ( 3500): CORE3282: stdout: loadStdYearlyInfo:class 8
[07/May/2012:10:03:06] info ( 3500): CORE3282: stdout: Hibernate: /* update com.aims.beans.Student */ update student set sname=?, sclass=?, tno=? where sno=?
[07/May/2012:10:03:06] info ( 3500): CORE3282: stdout: loadStdYearlyInfo2
如何在数据库中更新学生班级价值? 但这里的价值得到了更新。 让我知道。 是否有任何问题?