Spring Blazeds with Hibernate Session-In-View pattern



为了实现视图中的会话Hibernate模式,我使用了我的自定义Servlet过滤器:

public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    try {
        // Starting a database transaction
        sessionFactory.getCurrentSession().beginTransaction();
        // Continue the request 
        chain.doFilter(request, response);
        // Committing the database transaction
        sessionFactory.getCurrentSession().getTransaction().commit();
    } catch (StaleObjectStateException se) {
        // Some codes here
    }
}

看来事务将在处理请求后提交。但是,当我们使用SpringBlazeDS-Integration来序列化Flex的输出时,出现了一个问题:

BlazeDS在事务提交之前(在line-chain.doFilter处)通过使用惰性提取来序列化结果对象及其所有子对象。如此多的查询涌入数据库以获取对象,有时永远无法完成。

我该如何解决这个问题?是否有任何配置来限制BlazeDS中的序列化深度?

这不是你的问题的直接答案,但你可以看看GraniteDS:它提供了完全的延迟加载支持(请参阅此处和此处的文档),并与Spring框架进行了很好的集成(此处为文档)。

最新更新