When To Use Ejb

CategoryEjb


Due to recent discussion on whether ejbs are a worthwhile technology or just marketing hype, this page was started to provide an area to discuss when to or when not to use ejbs. This is a place to discuss thoughts on what problems/scenarios provide a good or bad reason to use EJB's. Lets include reasoning why such a problem is a good or poor choice for ejb's.


SessionBean tip Just use them.

EntityBean tips

Biggest problem with EntityBeans – marketing. Most people have impression that EntityBeans are some kind O/R mapping tool (RDBMS). NO! They were designed as a universal persistence layer. Even CMP should not be considered as O/R approach, please note: the name stands for Container Managed Persistence, not Database. The EntityBean persistence approach is far from being optimal for O/R mapping, but it is ONLY solution possible that allows persist data in different storages (DB, LDAP, file, ERP-system, mainframe), and to have relationship between them, and do transactions.

Yes, most applications need just DB persistence, and more optimal solutions are possible. Do I mean CMP must not be used? No, just beware N+1 problem (it is not a problem but feature), so do not be afraid of using plain SQL and JDBC to get lists of information about objects. Note: not objects!, but information about them, and only if user or system really wants to do CRUD upon an object, go EntityBean.

KonstantinIgnatyev


EJB ... is ONLY solution possible that allows persist data in different storages - not true anymore. There are some JDO implementations that can persist to at least DB, LDAP and file.


When to use EJB: Refactor into it LATER - you have UnitTests - until then YagNi. EJB is the biggest modern killer of developer productivity.


EJB is a (relatively) simple technology for server side components. You get transactions, security and good cluster implementations. Use it if you need those features. Don't use it if you don't need these features. Persistence can / shoule be implemented with JDO or CMP. But that is not the main point of EJB.

EberhardWolff

When you are sure that your project will not hit some EjbFlaws. JDO is not much different either.


If there is a need to use JavaDistributedTransaction, is EnterpriseJavaBeans the preferred (or only, as said in EjbsAndDistributedTransaction (in delete queue Apr05), but see it refuted in OnTopicButNotNeeded) way to go? -- dl Nov04, and no response by Apr05


EditText of this page (last edited April 4, 2005) or FindPage with title or text search