• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

session bean or entity bean?

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi -

I have to use EJB in a webservice to fetch data from the datatbase and return it to teh client.

Can some one please tell me which bean I should choose -- a session bean or an entity bean?

Thanks!
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It will depend upon the production scenario.

If you need to fetch data from database, and hit rate is higher Entity beans will be a good approach.
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ajay! I will proceed with entity beans as there will be heavy load.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure depends on the particular use case in question. However, I would be hard pressed to use entity beans. Especially if DB interaction is high, it may affect your performance. Besides you are gonna use this in webservice. If you are using Document centric message style, you will be doing your own XML conversion from the data returned. A Session bean with either direct JDBC call coupled with Javebean style DTO's, will porbably scale well. If database independence is not a requirement, then I might also look into the possibility of using stored procedure and calling it from Session bean. That way you can exploit DB specific features ( analytical functions, DECODE, DATE FORMATS in case of Oracle ) and return a result set back to session bean.
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Neelesh for getting back.

Yes, there will be a 'very heavy' traffic and there fore by what you guys have suggested, I will concentrate on using entity beans.
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hari Priya
----------------------------------------------------------
Thanks Neelesh for getting back.

Yes, there will be a 'very heavy' traffic and there fore by what you guys have suggested, I will concentrate on using entity beans

-------------------------------------------------------------------------

Hi,
May be I was not clear in my reply sorry.
I will NOT use entity beans !

My options would be :
1. Session bean calling a stored proc that returns resultset(s)
2. Session bean with plain jdbc.

For heavy DB traffic, entity beans will kill your app. They are good when your underlying schema is highly normalized and when only your app has exclusive access to the DB. With enterprise apps, most of the times, there are more than one applications talking to your data.
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just want to retrieve data I prefer Session Beans. You can use either stateful or stateless bean based on your requirement. Most of the web applications I worked using session beans not entity beans. You can use Session Beans with DAOs
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,

U go with Session beans .

That is the best way to get bettter performance.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic