Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Session Beans or Entity Beans  RSS feed

 
Dave Lawrence
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I'm new to EJB.
Should I always put my business logic inside a Session Bean instead of an Entity Bean or does this depend on the amount
of business logic to be incorporated.
 
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dave Lawrence:
Hi All,
I'm new to EJB.
Should I always put my business logic inside a Session Bean instead of an Entity Bean or does this depend on the amount
of business logic to be incorporated.

Dave,
the choice between Entity or Session does not depend on the amount of BL.
Basically, we can define an EntityBean as a data representation (a row of a database), and the SessionBean as an action (checkCreditCardNumber, placeOrder)..
For further information, take a look at : http://java.sun.com/j2ee/tutorial/1_3-fcs/index.html
or http://www.execpc.com/~gopalan/java/ejb.html
I'm sure others will give you interesting links too.
HTH
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good division of logic would call for the entity bean to represent persistent data. Since data is not logic, the entity bean should not contain BL.
 
Ananya Bhushan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Dave!
In order to distinguish whether to use a session bean or an entity bean as a thumb rule for a newbie is to have nouns as entity beansi.e (if u r developing an accounting package ya will have Customer, Account classes etc. as Entity beans) .If ya wish to go more in depth then Session Beans represent ur business logic where as Entity Beans are an object oriented representation of ur database ie. persistance storage.
 
Hari babu
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your Session bean represents the Biz Logic whereas u'r Entity bean represents Data logic
Hari
 
Dave Lawrence
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
thanks for all the replies.
I have a design problem using Entity Beans and Session Beans.
I have a dB Table that contains GroupPublication data. Each Publication is made up of many GroupPublications(i.e. adds all
the GroupPublications together).
My user front end(JSP) needs to be able to view all the Publication data and on another screen(JSP) view Group
Publication data.
Should I have the following:-
Entity Bean for GroupPublication,
Session Bean for Publication,
Session Bean for AllPublications, this will create each of the Publication Session Beans using the data
from GroupPublication Entity Beans.
Using this approach my front end JSP via a Servlet will do an initial connect to AllPublications using JNDI.
Is this the correct approach?.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!