This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes db access: entity bean vs stateless sb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "db access: entity bean vs stateless sb" Watch "db access: entity bean vs stateless sb" New topic

db access: entity bean vs stateless sb

tom walters
Ranch Hand

Joined: Feb 14, 2002
Posts: 34
when we need access to database tables in our business logic, we use a dao in the stateless session bean containing the business logic instead of creating an entity bean and having the stateless session bean access the entity bean. when would an entity bean be the prefered solution? what are the advantages of using them instead of a dao in a slsb?
Ranch Hand

Joined: Mar 06, 2001
Posts: 123
We opted to do the same ... slsb + daos ... IMHO, one would need entity beans if you have a transactional requirement ...for readonly data I would stick with slsb + daos. One classic article which enlightens this subject would be
[ October 02, 2002: Message edited by: Prashanth Joisha ]
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
I think with EJB 2.0, entity beans are becoming more popular because many of the performance problems have been solved. As Prashanth noted, they are more inline with using declarative services such as persistence and transactions.
John Carnell
Ranch Hand

Joined: Sep 27, 2002
Posts: 71
Hi all,
I originally wrote most of my DAOs using Stateless session beans. However, even with the release of the EJB 2.0 spec, for most of the work I do I find a lot of the OS OR mapping tools like Torque or OJB are just too darn easy to use?
What are your opinions? :,>

John Carnell<br />Principal Architect<br /> <br />Netchange, LLC<br />1161 HillCrest Heights<br />Green Bay, WI 54313<br /> <br /><br /> <br /> <br />Author of <a href="" target="_blank" rel="nofollow">Pro Jakarta Struts, Second Edition</a>
Edward Farrow
Ranch Hand

Joined: Apr 02, 2002
Posts: 32
i too prefer
slsb --> dao
instead of
slsb --> entity bean --> dao
what are the effects on performance and scaleability? would the entity bean solution have better performance and scaleability? are there any articles or whitepapers discussing the tradeoffs?
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
I think the entity bean camp argues now to
slsb --> entity bean (CMP)
instead of
slsb --> dao
slsb --> entity bean (BMP) --> dao
The CMP entity beans will be clustered by most containers so the scalability might be higher with them (although since it is recommended to use a session facade with local references I'm not really sure how this pans out). I don't see any general performance rationale, the benchmark would probably depend upon how well the container vendor implements the CMP.
[ October 06, 2002: Message edited by: Jim Baiter ]
I agree. Here's the link:
subject: db access: entity bean vs stateless sb
It's not a secret anymore!