Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session bean or entity bean?

 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • 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!
 
Ajay Singhal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks Ajay! I will proceed with entity beans as there will be heavy load.
 
nilesh Katakkar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Kj Reddy
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • 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
 
rakkesh kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,

U go with Session beans .

That is the best way to get bettter performance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic