File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes session bean or entity bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "session bean or entity bean?" Watch "session bean or entity bean?" New topic
Author

session bean or entity bean?

Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
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

Joined: Jan 10, 2001
Posts: 37
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

Joined: Mar 11, 2004
Posts: 134
Thanks Ajay! I will proceed with entity beans as there will be heavy load.
nilesh Katakkar
Ranch Hand

Joined: Oct 27, 2004
Posts: 35
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.


nilesh<br />neilindallas@hotmail.com
Hari priya
Ranch Hand

Joined: Mar 11, 2004
Posts: 134
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

Joined: Oct 27, 2004
Posts: 35
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

Joined: Sep 20, 2003
Posts: 1704
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

Joined: Oct 06, 2004
Posts: 37
hi ,

U go with Session beans .

That is the best way to get bettter performance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session bean or entity bean?