只是一个标记

来源:百度文库 编辑:神马文学网 时间:2024/04/30 11:11:31

     *session_context和事务边界 
    用current_session_context_class属性来定义context(用sessionFactory.getCurrentSession()来获得session),其值为: 
    1.thread: ThreadLocal来管理Session实现多个操作共享一个Session,避免反复获取Session,并控制事务边界,此时session不能调用close当commit或rollback的时候session会自动关闭(connection.release_mode:after_transaction). 
      Open session in view: 在生成(渲染)页面时保持session打开。 
    2.jta:由JTA事务管理器来管理事务(connection.release_mode:after_statement). 


   *悲观锁和乐观锁 
    悲观锁由数据库来实现;乐观锁hibernate用version和timestamp来实现