Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When to use what

 
Sanjay Balu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
in a shopping cart example, when SHOULD i use stateless, statefull, and entity beans. Using statefull beans will slow down my application, considerably, so what sould be my design pattern.please reply.
Considering the following tables.
1> login table, containing username password fields
2> Purchase order table containing, client_id, purchase_order_id, no_of orders.
Should the bean that acesses my database be a stateful bean, what would be the best design pattern

thanks,
Sanjay
[ February 14, 2002: Message edited by: Sanjay Balu ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use an entity bean to represent persistent data (data in a database for example). Use a stateful bean when you need to save state. When will you need to do that? Rarely. Use stateless beans for business logic that doesn't need to maintain state.
The stateless-staeful argument comes to this:
You need to save state so where do you keep it:
1) hidden fields on the client
2) a Session object
3) stateful session bean
1 and 2 have the advantage of being less resource intensive but they have the disadvantage of forcing you to rebuild state in the EJB server. You have to pass the current state to a stateless bean so it can figure out where it is and what it needs to do next. So if the cost of recreating state is expensive (a lot of database lookups, for example) then use a stateful bean. If the cost of recreating state is cheap (just capture some data passed from the client) then use stateless beans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!