java 会话 bean 和实体 bean、有状态会话 bean 和无状态会话 bean 之间的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13501503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Differences between session beans and entity beans, and stateful session beans and stateless session beans
提问by Hypnoz
I use SSH for a some while, and some friends ask me what is bean, and difference between session bean and entity bean, and difference between stateful session bean and stateless session bean, is those concept only exists in EJB(I also want to ask is EJB some relation with SSH), or they are general concept? and what are they?
SSH用了一段时间,有朋友问我什么是bean,session bean和entity bean的区别,stateful session bean和stateless session bean的区别,是不是只有EJB才有这些概念(我也想问EJB 是否与 SSH 有某种关系),或者它们是一般概念?它们是什么?
what i mean SSH is Spring Struts and Hibernate, actually i do not know they three has some relationship with EJB?
我的意思是SSH是Spring Struts和Hibernate,其实我不知道他们三个和EJB有什么关系?
And i want to know is that bean is concept in the context of EJB? And when we talks about other framework like SSH, we never said bean?
我想知道 bean 是 EJB 上下文中的概念吗?当我们谈论其他框架如 SSH 时,我们从来没有说过 bean?
回答by Tomasz Nurkiewicz
what is bean
什么是豆
In context of EJB, bean is a class managed by the container.
在 EJB 的上下文中,bean 是由容器管理的类。
between session bean and entity bean
会话 bean 和实体 bean 之间
Session beans represent logic while entity beans represented persistent objects. These days entity beans aren't used anymore in favour to JPA entities.
会话 bean 代表逻辑,而实体 bean 代表持久对象。现在实体 bean 不再用于 JPA 实体。
difference between stateful session bean and stateless session bean
有状态会话 bean 和无状态会话 bean 的区别
Once you obtain a reference to stateful session bean, you will always use that particular instance. Stateless session beans are pooled and returned to the clients at random.
一旦获得对有状态会话 bean 的引用,您将始终使用该特定实例。无状态会话 bean 被汇集并随机返回给客户端。
those concept only exists in EJB
那些概念只存在于 EJB
Yes, although beans are also present in Spring framework with a similar meaning but different design concepts.
是的,虽然 bean 也存在于 Spring 框架中,其含义相似但设计理念不同。
is EJB some relation with SSH
EJB 和 SSH 有什么关系
You can deploy EJBs via SSH using SCP. But seriously, seems like you are confusing SSH with...?
您可以使用 SCP 通过 SSH 部署 EJB。但是说真的,您似乎将 SSH 与...混淆了?