File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Why should we use Enity Beans? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Why should we use Enity Beans?" Watch "Why should we use Enity Beans?" New topic
Author

Why should we use Enity Beans?

Mahesh Kaila
Greenhorn

Joined: May 24, 2001
Posts: 1
Please help me to clear my doubts...
I have few questions here...
1. Why should we use Entity Bean?
2. I have to make sql join queries more frequently in my application, does the enity beans support joing queries?
3. Inorder to imporove the performance of Application server the entity beans must be destroyed if they are not in use, how can i destroy entity beans? I don't understand when entity beans gets destroyed?
4. Does Entity Beans supports Data Cache?
5. How Entity Beans are benificial over Stateless and State-full Session Beans?
Thanks in advance,
Mahesh
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
I also would like to know, why
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Entity beans are probably one of the most controversial technologies within J2EE and is a fairly large and complex topic. To summarise some answers for your questions...
(1) Entity beans are generally used to represent persistent information - for example customers within your application.
(2) Yes, since EJB 2.0, entity beans support the notion of Container Managed Relationships (CMR) meaning that you can declaritively define relationships between your entity beans. Of course, you can still program these relationships yourself if required.
(3) In terms of entity beans being destroyed to aid performance, this isn't strictly true. In fact, the Java objects representing entity beans can be passivated by the container when they have not been accessed for a specific time. This enables the container to free up resources. Subsequent requests for those entity beans result in the activation of those passivated instances.
(4) Most application servers support some degree of data caching. When you introduce clusters into the equation, the issues around data caching become much more complex through aspects such as distributed locking and ensuring the caches are kept up to date.
(5) Entity beans are another tool in your toolbox and provide a very easy framework/architecture with which to build the persistent objects that are a part of your application. Stateful and stateless session beans are generally used to represent business processes, and therefore compliment entity beans rather well.
Hope these (rather simplified) answers help.
Simon
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Here is a link to a similiar topic from a while back: Best design practices.
Let me start by saying that I am not a very big fan of Entity Beans. However, like many other things, Entity Beans definitely have a place. If you are looking for a persistance engine then I think CMP 2.0 is pretty good. It definitely still has many limitations, but right now CMP is the only well supported standards-based persistance engine. This could very well change in the future with the growing popularity of technologies such JDO.
My view is, if you want free persistance and you are willing to deal with some of CMP's limitations, then Entity Beans are a fair choice.
However, if persistance is not a big concern and you are looking to take advantage of the other benefits of EJB, then I would say you should skip Enity Beans completely. JDO or POJO wrapped with Session Beans would be a much better solution in this case.
Guennadiy VANIN
Ranch Hand

Joined: Aug 30, 2001
Posts: 898
Thanks a lot Simon and Chris.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why should we use Enity Beans?