This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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
Author

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?
pjoisha
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
http://www7.software.ibm.com/vad.nsf/Data/Document2361?OpenDocument&p=1&BCT=66
PJ
[ 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
Author
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 />john.carnell@netchange.us<br /> <br /> <br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/159059228X/ref=jranch-20" 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
or
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: http://aspose.com/file-tools
 
subject: db access: entity bean vs stateless sb
 
Similar Threads
J2EE, encapsulation & data with operations
Use of DAO in SCJEA Assignment
Business Logic in EJB3 SessionBean?
Stateful session beans or Stateless combined with entity beans
business logic and ejb