• Post Reply Bookmark Topic Watch Topic
  • New Topic

When would you use session EJBs as opposed to entity EJBs

 
Naina Si
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When would you use session EJBs as opposed to entity EJBs?
 
Vicky Mohan
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity EJBs are primarily used for making data persistent. When you want to create / update / delete an entity , you can use entity EJBs either through Container Managed Persistence OR Bean Managed Persistence.

Session EJBs are used for business logic. They perform select operations.
 
Saritha Penumudi
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The below listed are some of my observation. Please correct me If my understanding is wrong.

Session Beans:
- mostly used for the business Logic.
- If there is no requirement to track or persist client request state then stateless session beans would be best option.
- If application require to get lots of data in the form of thousands and thousands of records, then writing a session bean with JDBC calls and JTA will be best option.

Entity Beans:
- When there is less data that have to be retrieved from the database.
- If retrieving data involves complex logic (Joins) then BMP is best option
- If data retrived directly maps to one table and there is no much logic involved then CMP is best option.

Cons with EntityBeans:
- It is always better to code Entity Beans as Local than Remote. Hence we need to write a session facade that would invoke these entity beans.
Question: I always had a question here. Now, when we are using remote session beans as a session facade for local entity beans, how we are improving performance. What difference it makes declaring a session bean as remote to declaring it as an Entity bean. I mean what external processing is being done when an entity bean is declared as remote compared to a session bean that is declared a Remote.
- The number of entity beans created is equal to the number of records retreived from the database. Now if app is generating report which need to show 1000 and 1000 records then so many entity beans are created which is burden to the server.

Security, Transaction concepts work same for both Session and Entity Beans.
[ October 29, 2004: Message edited by: Saritha ventrapragada ]
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Saritha ventrapragada:
The below listed are some of my observation. Please correct me If my understanding is wrong.

Question: I always had a question here. Now, when we are using remote session beans as a session facade for local entity beans, how we are improving performance. What difference it makes declaring a session bean as remote to declaring it as an Entity bean. I mean what external processing is being done when an entity bean is declared as remote compared to a session bean that is declared a Remote.



We are using session fecade to avoid the network load. Session ejb will deal with entity beans business object in the same network when using the session fecade.

When we are declaring the entity bean as remote, I think the it will always try to create (I am not sure the exact definition!) the network link if both the session bean and entity reside in the same app server, which takes time and load. To avoid that we have to declare the entity bean as local to the session bean if both the bean reside in the same app server.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!