3

A project I'm working on is going to upgrade from jee5/seam to jee6, where "those who descide" think it is a good idea to drop seam since most of its features have been incorporated into jee6. But I have a case that I doesn't seem to be able to solve in jee6.

We have several wizards using ConversationScope. We use Seams FlushModeType.Manual in order to avoid getting "dirty" data commited until we want we actually wants to commit it (each page-load basically gets it own transaction but since nothing is written to the database until we flush, most commits doesn't change the state of the database).

I have made a few attempts using PersistenceContextType.EXTENDED in jee6 but it seems like I can't find a way to defer the flush to the database like seam does and the only workarounds seems to be to use detached objects or a separate view-model.

We really like how working with attached objects make (for our cases) things really simple to understand and fast to develop.

Is there a solution where we can keep working with attached objects in conversations?

4

1 回答 1

2

作为 Seam2 的忠实粉丝,我使用对话、对话范围实体管理器以及将刷新模式设置为手动和分离对象的对话范围实体管理器编写了出色的应用程序。

然而,我们现在必须承认,尽管这种模式在 Seam 手册中被大力推动,并且就 Hibernate 是 JPA 实现而言工作得很好,但它从根本上被打破了。原因在 Mark Struberg 的这篇文章中进行了解释:有没有办法修复 JPA EntityManager?

所以,答案是否定的,没有切实可行的解决方案可以在对话中继续使用附加对象。您应该使用分离的对象。

还有另一位伟大的 CDI 博主尝试了会话范围的实体管理器:Conversational CRUD。如果您继续尝试使用附加对象,则可能值得一读。

于 2013-05-15T09:36:04.597 回答