【问题标题】:openSessionInView implementation and LOCKopenSessionInView 实现和 LOCK
【发布时间】:2012-05-15 16:55:25
【问题描述】:

我正在尝试使用 Spring 2.5.5 Flex/J2EE 和 Hibernate 3.1.3 开发应用程序。 我的问题是当用户打开“客户信息”屏幕然后以更改模式显示客户信息时,我希望适当地锁定记录(悲观或乐观锁定锁定)。并且注册保持锁定状态,直到用户验证更改(提交())或关闭屏幕。

他们在网上谈论长对话(休眠)和 openSessionInView 模式。但是我还没有找到一个明确的例子。

解决方案是保持 Hibernate 会话打开直到进入结束。 然后进行提交或回滚。

我尝试使用类:“org.springframework.orm.hibernate3.support.OpenSe ssionInViewInterceptor”但我没有成功。 我不知道如何使用 Spring 进行配置。

我花了太多时间,它变得紧急......谁可以帮助我?

提前谢谢你。

【问题讨论】:

    标签: spring hibernate locking


    【解决方案1】:

    OpenSessionInViewInterceptor 必须在你的 web.xml 中配置

    示例如下:

        <filter>
            <filter-name>openSessionInViewFilter</filter-name>
            <filter-class>
               org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
            </filter-class>
            <init-param>
                 <param-name>sessionFactoryBeanName</param-name>
                 <param-value>sessionFactory</param-value> <!-- This is the default value, in case you have given different name please specify the same. -->
            </init-param>            
        </filter>
    

    还可以查看documentation 以了解细微问题。

    【讨论】:

      猜你喜欢
      • 2018-01-01
      • 2019-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      相关资源
      最近更新 更多