Java Reference
In-Depth Information
Detached objects
EJB 2 applications use DTO s to exchange data between the presentation tier and
the business tier. Developing and maintaining the DTO s and the code that creates
them is often a significant amount of work. It is also quite tedious. EJB 3 eliminates
most uses of DTO s by supporting Hibernate-style detached objects. When a trans-
action ends, all entity beans that were loaded during the transaction are automat-
ically detached and can be returned to the presentation tier. The presentation tier
can also modify a detached entity bean and then pass it back to the business tier,
which can reattach it to update the database.
So as you can see, EJB 3 is significantly better than EJB 2 . If you have never used
a lightweight technology such as Spring, Hibernate, or JDO , you will be pleasantly
surprised by how easy it is to use. But, as of this writing, when compared to those
lightweight technologies EJB 3 still has some significant issues and drawbacks.
Let's take a look.
10.1.2
Key limitations of EJB 3
Like every technology, EJB 3 has some limitations and issues that make develop-
ment more difficult. Some are limitations of the ORM mechanism as described by
the June 2005 public draft and will likely be fixed before the final version of the
specification. Other issues, such as the development time complexity that lurks
beneath the surface, are an inherent part of the EJB concept itself. They are
caused by the reliance of session and message-driven beans on the EJB container
and application server-side technologies such as JNDI . Let's review each of the
issues and drawbacks.
Limited support for collections
In the radio series “Hitchhiker's Guide to Galaxy,” Ford Prefect and Arthur Dent
get stranded on Earth two million years in the past with the Golgafrinchams. After
a year or so, the Golgafrinchams, who are the human race's ancestors, have failed
to discover fire or invent the wheel. The development subcommittees responsible
for these two inventions cannot decide how people will use fire or what color
wheels should be. As you can imagine, Ford and Arthur were very frustrated.
I sometimes feel as frustrated about the collection support in EJB 3 . It's certainly
much better than what is in EJB 2 , but it is still inferior compared to JDO and Hiber-
nate. For example, EJB 3 only supports collections of entities. You cannot, for
example, have collections such as Set<String> or Set<Integer> , which are quite
common in a POJO domain model and are supported by Hibernate and JDO . As
you will see later, you have to replace these kinds of collections with collections of
entity beans that wrap the value, which often requires a lot of extra code.
 
 
 
 
 
Search WWH ::




Custom Search