示例或用途解释EJB事务属性的案例 [英] Examples or Uses Cases to explain EJB Transaction Attributes

查看:181
本文介绍了示例或用途解释EJB事务属性的案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对EJB事务属性(和注释)有一些很好的解释,例如, OpenEJB的

There are some good explanations of EJB Transaction Attributes (and annotations) out there, for example, OpenEJB's.

但是有时当我试图用没有使用过许多交易资源的人来掩盖这一点时,我看到他们的眼睛开始上釉。

But sometimes when I try to cover this with someone who hasn't worked with many transactional resources, I see their eyes start to glaze over.

所以我的问题 - 您如何向祖母解释EJB交易属性?

So my question - how would you explain EJB Transaction Attributes to your grandmother?


  • 必填

  • RequiresNew

  • 强制性

  • NotSupported

  • 支持

  • 从不

  • Required
  • RequiresNew
  • Mandatory
  • NotSupported
  • Supports
  • Never

我在想一个人为的例子,类比或简洁的真实-world用例会有所帮助。

I'm thinking a contrived example, analogy, or a concise real-world use case would be helpful.

推荐答案

我认为根据容器与a的交互来考虑这个问题是有意义的。调用EJB方法作为真正的监视器 ...所以我想在各种不同的场景中使用保镖隐喻

I think it makes sense to think about this in terms of the container's interaction with a caller to the EJB method as a true monitor... so I'd like to use a bouncer metaphor in various different scenarios.

请参阅此页面有关交易属性的良好描述/概述。

See this page for a good description/overview of the transaction attributes.

必需(必需@TransactionAttribute)

夜总会

出现在俱乐部,需要一张入场券。如果你没有,它会在门口给你(购买?)。

Show up at the club, need a ticket to enter. If you don't have one it will be (purchased?) given to you at the door.


交易是门票。

容器是BOUNCER。

Transaction is the TICKET.
Container is the BOUNCER.

需要新的(REQUIRES_NEW @TransactionAttribute)

喜剧俱乐部,最少1杯饮料,无需重新入场

出现在俱乐部,没有外面的食物/饮料,你必须把它们留在门口。要进入,你必须在每次离开时重新输入1杯饮料。

Show up at the club, no outside food/drink, you must leave them at the door. To get in you must purchase 1-drink minimum every time you leave and re-enter.


交易是饮品。

Container是BOUNCER。

暂停交易是在门口离开。

Transaction is the DRINK.
Container is the BOUNCER.
Suspending the transaction is LEAVING AT THE DOOR.

支持(SUPPORTS @TransactionAttribute)

众议院派对

出席聚会,允许饮酒。如果你有自己的酒,我们会让你进去,如果你不这样做,我们也会让你进去。

Show up at the party, alcohol is permitted. We'll let you in with it if you have your own alcohol, if you don't we'll let you in too.


交易是ALCOHOL。

容器是主机。

Transaction is the ALCOHOL.
Container is the HOST.

强制性(强制性@TransactionAttribute)

仅邀请派对

在派对上出现,需要输入邀请:如果你没有一个并试图进入,保镖会打电话给当局。

Show up at the party, need a invitation to enter: If you don't have one and try to get in, the bouncer calls the authorities.


交易是邀请。

容器是主机。

抛出异常就是要求当局。

Transaction is the INVITATION.
Container is the HOST.
Throwing an exception is CALLING THE AUTHORITIES.

不支持( NOT_SUPPORTED @TransactionAttribute)

音乐会,禁止使用相机。

出席音乐会,相机被禁止。您可以将它留在门口并在离开时将其取出。

Show up at the concert, cameras are prohibited. You can leave it at the door and pick it up when you leave.


交易是CAMERA。

容器是DOORMAN。

暂停交易是在门口离开。

Transaction is the CAMERA.
Container is the DOORMAN.
Suspending the transaction is LEAVING AT THE DOOR.

从不(从不@ TransactionAttribute)

高中舞蹈

出现在舞会上,禁止饮酒。如果你试图接受它并被抓住,那么监护人会打电话给当局。

Show up at the dance, alcohol is prohibited. If you try to get in with it and are caught, the chaperone calls the authorities.


交易是ALCOHOL。

Container是CHAPERONE。
抛出异常就是要求当局。

Transaction is the ALCOHOL.
Container is the CHAPERONE. Throwing an exception is CALLING THE AUTHORITIES.

这篇关于示例或用途解释EJB事务属性的案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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