-1

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

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

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

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

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

先感谢您。

4

1 回答 1

0

必须在 web.xml 中配置 OpenSessionInViewInterceptor

下面的示例:

    <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>

还要检查文档中的细微问题。

于 2012-05-15T17:03:59.657 回答