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

查看:96
本文介绍了从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,并将业务逻辑从会话Bean转移到Spring Bean,即数据访问对象(扩展了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).

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

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.

任何建议都将不胜感激.

Any suggestion are greatly appreciated.

推荐答案

如果您只是出于 think 的考虑将完美的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.

我建议您将服务器从JBoss AS 4升级到6,而不是迁移到Spring,或者如果您可以忍受等待,请等待几个月,然后直接使用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.

P.s.如果您已经有一个运行良好的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天全站免登陆