static Department add(){
Session s = null;
Transaction tx = null;
try{
Department depart = new Department();
depart.setName("depart");
Employee employee1 = new Employee();
employee1.setName("employee1");
employee1.setDepart(depart);
Employee employee2 = new Employee();
employee2.setName("employee2");
employee2.setDepart(depart);
s = HibernateUtil.getSession();
tx = s.beginTransaction();
s.save(depart);
s.save(employee1);
s.save(employee2);
tx.commit();
return depart;
}finally{
if(s != null)
s.close();
}
}
这段代码在myeclipse中运行、当我用 tx.commit();提交事务的时候、数据库中
虽然已经更新了、但是myeclipse中的进程还是没有关、就是控制台的那个红点没有熄灭?查看数据库此时事务还是由myeclipse控制、当我把事务停止(手动停止myeclipse中)事务的时候、数据库中就可以操作了、说明此时myeclipse还是没有释放锁、不明白为什么?