openSession() 和 getCurrentSession() 方法主要有两个区别:
1.getCurrentSession在事务提交或回滚之后会自动关闭,而openSession需要手动关闭,如果使用openSession而没有手动关闭,多次之后会导致连接池溢出。
2.openSession每次都创建新的session对象, getCurrentSession使用现有的session对象。
openSession() 和 getCurrentSession() 方法主要有两个区别:
1.getCurrentSession在事务提交或回滚之后会自动关闭,而openSession需要手动关闭,如果使用openSession而没有手动关闭,多次之后会导致连接池溢出。
2.openSession每次都创建新的session对象, getCurrentSession使用现有的session对象。