• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When to use what

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic