在长时间运行的对话中,Wicket和Hibernate之间安全地传递信息 [英] Passing information safely between Wicket and Hibernate in long running conversations

查看:87
本文介绍了在长时间运行的对话中,Wicket和Hibernate之间安全地传递信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



作为用户界面的一部分,我们有很长时间的运行对话,跨越多个请求,然后更新的信息被写回数据库。

为了避免使用分离对象获得休眠错误,我们现在使用值对象将信息从服务层传递给Wicket。



然而,我们现在最终会爆发几乎相同的对象:

例如
$ b


  • Answer(映射实体保存在hibernate中)

  • AnswerVO(不可变值对象)
  • >
  • AnswerModel(会话域中的可变bean)

  • IModel包装Wicket模型

  • 一个CompoundPropertyModel


这个管道在与对象有关的其他对象的集合中呈指数级地变差。



必须有更好的方式来组织这项工作。



任何人都可以分享提示,以减少繁重的工作吗?

也许让值对象变为可变的,这样我们就可以在Wicket中删除需要分离的支持bean?



使用实体bean,但绝对会造成死亡 - 某些他们从冬眠分离。 (说起来容易做起来难)



其他一些技巧或模式?

解决方案

通常的解决方案将是视图模式中的公开会话,参见例如 osiv with wicket



我对OSIV没有很好的经验,所以我建议在GUI层下面设置事务边界,并在商业或服务层中巧妙地计划数据检索来解决臭名昭着的lazyInitializationException


We are using Wicket with Hibernate in the background.

As part of out UI we have quite long running conversations spanning multiple requests before the updated information is written back to the database.

To avoid getting hibernate errors with detached objects we are now using value objects to transfer info from the service layer to Wicket.

However we now end up with an explosion of almost the same objects :

e.g.

  • Answer (mapped entity saved in hibernate)
  • AnswerVO (immutable value object)
  • AnswerModel (A mutable bean in the session domain)
  • IModel wrapped Wicket Model
  • and usually this gets wrapped in a CompoundPropertyModel

This plumbing becomes exponentially worse when collections to other objects are involved in the objects.

There has to be a better way to organize this.

Can anyone share tips to make this less onerous?

Maybe make the value objects mutable so we can remove the need for a seaprate backing bean in Wicket?

Use the entity beans but absolutely make dead-certain they are detached from hibernate. (easier said than done)?

Some other tricks or patterns?

解决方案

the usual solution would be the open session in view "pattern", see e.g. osiv with wicket

i have no good experiences with OSIV, so i rather advise to set transaction boundaries below the GUI layer and solve the infamous lazyInitializationException with clever planned data retrieval in business or service layer

这篇关于在长时间运行的对话中,Wicket和Hibernate之间安全地传递信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆