是否使用 EJB3?
我有一个架构场景,我想讨论一下以征求您的意见。
我可以在这两者之间进行选择(这是对我的限制)
- 使用 EJB3+JPA - 没有 Spring/Hibernate
- POJO + JDBC - 再次没有 Spring/Hibernate
我有一系列的 Web 应用程序(只有 Intranet),所有这些应用程序都需要集成。 在数据库级别,将有 3 到 4 个 Oracle 数据库(每个数据库大约有 40 到 50 个表)。 某些应用程序可能会与多个数据库交互以进行某些查询。 并发用户数将少于 100。每个应用程序的用户/受众范围为 10 到 6000(最多)。
所有应用程序都将部署在一台服务器上,并且数据库和服务器很可能位于同一台计算机上。
大多数用例将基于 CRUD(有些可以为 ORM 提供良好的域模型,而另一些则不能),以及一些业务流程、自动化作业等。未来可能需要与 SAP 集成某些应用程序。
您认为本例中的 EJB3 会使应用程序更具可扩展性还是只会增加复杂性? 如果我用 POJO 进行设计,我不想无缘无故地增加复杂性。 我尝试游说 Spring 和 Hibernate,但没有成功。
如果您需要更多详细信息,请告诉我。
编辑:我忘了提及应用程序服务器。 现在是 7 点。
I have an architecture scenario and I would like to discuss to get your opinion.
I can choose between these two (this is a constraint imposed on me)
- Use EJB3+JPA - no Spring/Hibernate
- POJO + JDBC - again no Spring/Hibernate
I have series of web applications (only intranet) that all need to be integrated. At database level, there will be 3 to 4 oracle databases (and about 40 to 50 tables per database). Some applications may interact with more than one database for some queries. Number of concurrent user(s) will be less than 100. User/audience per application will range from 10 to 6000 (max).
All applications will be deployed on one server, and it's very likely that database and server could be on the same machine.
Most of the use cases will be CRUD based (some can offer a good domain model for an ORM while others may not), with some business process, automated jobs etc There may be a future need to integrate with SAP for some applications.
Do you think EJB3 in this case will make the application more scalable or just add complexity? If I design with POJO, will an application of this I don't want to add complexity for no good reason. I tried to lobby for Spring and Hibernate but no success.
let me know if you need more details.
EDIT: I forgot to mention the application server. it's WAS 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
EJB和JPA只是接口; 你仍然需要有人来实施它们。 因此,如果 Spring+Hibernate 不可行,那么这意味着没有 JPA,除非您可以为另一个框架获得 OK(...呃...Toplink,也许?有没有任何东西不是基于 Hibernate?)
如果您受困于 POJO 和 JDBC,我建议您查看 Grails。 这将使您的生活变得更加简单。
EJB and JPA are just interfaces; you'll still need someone to implement them. So if Spring+Hibernate aren't possible, then this means no JPA unless you can get an OK for another framework (... err ... Toplink, maybe? Is there anything which isn't Hibernate based?)
If you're stuck with POJO and JDBC, I suggest to look at Grails. That will make your life much more simple.
我不明白如何允许 JPA,但 Hibernate 不会。 鉴于 Hibernate 是 JPA 实现,这没有多大意义。 其他 JPA 实现是否可以,例如 OpenJPA?
您没有提到您是否有现有服务器,或者是否将在尚未选择的服务器上安装您的应用程序。 这个决定已经做出了吗? 如果是这样,这可能会决定您的选择。 完整的、最新的 JavaEE 服务器将附带 EJB3 和 JPA 实现。
如果服务器不是支持 EJB3 的服务器,那么 EJB3 的吸引力就小得多。
但是,如果排除了 Spring 和 Hibernate 等明智的技术,那么总有 iBatis 等简单的框架允许您将 POJO 与 JDBC 结合起来。
I can't see how JPA would be permitted, but Hibernate wouldn't. That doesn't make a lot of sense, given that Hibernate is a JPA implementation. Would another JPA implementation be OK, such as OpenJPA?
You haven't mentioned if you have an existing server, or will be installing your apps on a yet-to-chosen server. Has this decision already been made? If so, that may dictate your choice. A full, up-to-date JavaEE server will come with EJB3 and JPA implementations already.
If the server isn't an EJB3-enabled server, then EJB3 is much less compelling.
But if sensible technologies such as Spring and Hibernate have been ruled out, there always simple frameworks like iBatis that allow you to combine POJOs with JDBC.
第一级讨论是将{POJO + JDBC,手工编写持久性}与{持久性框架}进行比较。 (我还怀疑您最终会需要有趣的服务,因此我认为 EJB3/SLSB 或 Spring 等效项是相关的,即使您要推出自己的持久性)。
因此,我相信持久性技术(JPA 或 Hibernate)现在已经达到了您需要有充分理由不使用它们的水平。 手动增删改查 JDBC 只是例行工作,不应该手动完成。
至于 JPA 与 Hibernate 和 Spring 与 EJB3 的争论,我很模棱两可,似乎是一个充满宗教色彩的领域。
First level of discussion is to compare {POJO + JDBC, write persistence by hand} against {framework for peristence}. (I'd also suspect that you're going to end up with a need for interesting services, so I think EJB3/SLSB or Spring equivalent is relevent, even if you were to roll your own persistence).
So my belief is that persistence technologies (JPA or Hibernate) are now at a level where you need a good reason not to use them. hand-rolling crud JDBC is just routine work one should not have to do by hand.
As for the JPA v Hibernate and Spring v EJB3 debates, I'm much moe equivocal, seems to be an area with much religion.
尽管您的限制有些矛盾(Hibernate 毕竟是 JPA 实现),但我建议您采用标准解决方案。 如果您唯一的选择是像 EJB3/JPA 这样的标准堆栈与手工制作的 POJO/JDBC 实现,我会说选择 EJB3。
当您走上 POJO/JDBC 之路时,您可能最终会创建自己的类似 Spring 的框架,但功能不太丰富,测试也不太充分。 对于应用程序开发人员来说,编写自定义框架几乎是不合理的。
Although your constrains are somewhat a contradictory (Hibernate is a JPA implementation after all) I would advice you to adopt a standard solution. If your only choices are a standard stack like EJB3/JPA vs. a handcrafted POJO/JDBC implementation I'd say go for EJB3.
When you take the POJO/JDBC road you'll probably end up creating your own Spring like - but less feature rich and less well tested - framework. Writing a custom framework is hardly ever justifiable for application developers.
就EJB+JPA吧!
我猜你陷入了一些“企业”环境,并且无法使用开源框架..如果是这种情况,我猜上述接口的某些 IBM 或 Oracle 实现是可用的 - 使用它。
Just go EJB+JPA!
I guess you're stuck in some "corporate" env and you cannot use open source frameworks .. if this is the case I guess some IBM or Oracle implementation of the above interfaces is available - use it.
WAS 7 默认提供了 OpenJPA 实现。 春天+
WAS 7 defaultly has the OpenJPA implemenation provided. Spring+
EJB3+JPA 将使您的工作变得非常简单。它具有高度可扩展性,并且非常容易配置和相互使用。创建实体是最困难的部分,但之后事情就变得像 java 明智的了(特别是如果您使用实体关系)..我使用spring 和 hibernate 已经使用了 4 年,是的,如果您没有应用程序服务器,它们非常好。 但只要你有 WAS 7.0 那么我建议使用 EJB+JPA。
对于 java 程序员来说,使用 JPQL 更加容易和合理。 然而; 除非使用 JPA 2.1,否则无法调用存储过程,而 JPA 2.1 仅在 WAS 8.5 中受支持。
EJB3+JPA will make you work very simple..It's highy scalable and very easy to configure and use with each other.Creating entities is the toughest part but after that things go java wise(Specially if you use entities relationships)..I used spring and hibernate for 4 years and yes they are excellent if you don't have an application server. But as long as you have WAS 7.0 then i recommend using EJB+JPA.
Working with JPQL is far easier and reasonable to java programmers. However; you can't call stored procedures unless you use JPA 2.1 which is supported only in WAS 8.5.
答案很简单——
如果是jboss/glassfish,则使用EJB3
如果是tomcat,使用纯JPA,或者Hibernate或Spring数据
EJB3 vs Hibernate? 当然是EJB3。 你应该知道jboss下的EJB3用的是hibernate,glassfish下的EJB3用的是eclipse链接JPA。
Answer is simple -
If jboss/glassfish, use EJB3
if tomcat, use pure JPA, or Hibernate or Spring data
EJB3 vs Hibernate? of course EJB3. You should know what EJB3 under jboss used hibernate, EJB3 under glassfish used eclipse link JPA.