从 EJB3 迁移到 Spring、Hibernate [英] Migrating from EJB3 to Spring, Hibernate

查看:33
本文介绍了从 EJB3 迁移到 Spring、Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个基于 EJB3、Oracle 10 和 JBoss 4 的桌面应用程序.这是大约三年前创建的.JPA 实体用于 ORM,业务逻辑在无状态会话 bean 中实现.客户端是使用 Swing API 开发的.

We have a desktop based application based upon EJB3, Oracle 10 and JBoss 4. This was created around three years back. JPA entities were used for ORM and the business logic was implemented in the Stateless Session beans. The client was developed using Swing API.

现在需要用 Spring、Hibernate 和 JBoss 替换以前的技术,以用于下一个应用程序版本.客户端仍将在 Swing 中.计划是用 POJO 替换实体,并将业务逻辑从 Session Beans 放到 Spring Beans,即数据访问对象(扩展 HibernateDaoSupport).

Now there is a requirement to replace the previous technology with Spring, Hibernate and JBoss for the next release of application. Client will still be in Swing. The plan is to replace the entities with POJOs and put the business logic from Session Beans to Spring Beans i.e. Data Access Objects (which extend HibernateDaoSupport).

那么问题是,我们有没有可能将我们的应用程序完全从 Session Beans 中解放出来,并将业务逻辑移到 Spring Dao 上?还是我们仍然需要保留会话 Bean?如果完全避免使用会话 Bean,客户端应用程序将如何访问业务方法?与基于 JavaEE 的应用程序一样,会话 bean 可通过 Jndi 查找访问.

So the question is, is it possible that we completely free our application from Session Beans and move the business logic to Spring Dao? Or do we still have to keep the Session Beans? If Session Beans are completely avoided, how will the client application be able to access the business methods? Like in case of JavaEE based app, the session beans were accessible through Jndi lookup.

非常感谢任何建议.

推荐答案

如果你将一个完美的 EJB3/JPA 应用程序迁移到 Spring/Hibernate 只是因为你认为最终结果会更轻量级,那么恕我直言,您这样做是出于错误的原因,您可能正在考虑浪费大量的工程工作.

If you are migrating a perfectly fine EJB3/JPA application to Spring/Hibernate just because you think the end result will be more lightweight, then IMHO you're doing it for the wrong reasons and you may be looking at wasting a massive amount of engineering effort.

Spring 和 EJB3 都非常相似.Spring 在 XML 部门历来是重量级的,但现在它更紧密地遵循 EJB3 基于注释的方法.总的来说,两人似乎是在进行一场兔子跳跃比赛.有时Spring创新并领先一跳,但随后EJB3创新并再次领先一跳.两者都不断地以对方的特征为基础.

Spring and EJB3 are both fairly similar. Spring was historically more heavyweight in the XML department, but it now follows EJB3's annotation based approach more closely. In general, the two seem be in a bunny hopping contest. Sometimes Spring innovates and is one hop ahead, but then EJB3 innovates and is one hop again. Both constantly base their features on that of the other.

我建议您不要迁移到 Spring,而是将您的服务器从 JBoss AS 4 升级到 6,或者如果您可以忍受等待,请等待几个月并直接使用 JBoss AS 7.

Instead of migrating to Spring, I would suggest to upgrade your server from JBoss AS 4 to 6, or if you can tolerate the wait, wait a couple of months and go straight for JBoss AS 7.

附言如果您已经有一个完美运行的 Spring 应用程序,我也不建议仅仅为了变得更轻量级而迁移到 EJB3.

P.s. if you already had a perfectly fine working Spring application, I would also not advice migrating to EJB3 just for becomming more lightweight.

这篇关于从 EJB3 迁移到 Spring、Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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