wood burning stoves 2.0*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Session beans and Dao Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Session beans and Dao " Watch "Session beans and Dao " New topic
Author

Session beans and Dao

Muhammad Ahsan Jamshaid
Ranch Hand

Joined: Jun 01, 2006
Posts: 59
Hello Friends,
i am designing a test architecture for my j2ee application. I have following queries regarding design patterns.

1) can session bean be used in replace of Daos? if yess! then under what possible scenario?( in fact, some one commented me that session bean and dao can be used as alternatives of each other... whereas my point of view is that session bean captures business object and business flows and dao separates the data access mechanism)

2) benefits of using business delegates over session beans? Are'nt these two do the same ?

thanks,
Ahsan Jamshaid....


--Ahsan Jamshaid... SCJP 5(80%)
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
Hi Ahsan Jamshaid,

I think I don't understand your question... but:

1/ DAO can be implemented with Stateless Session Bean or POJO.
With JPA in J2EE 5.0, implementing a DAO with a Stateless SB is really simple.

2/ The definition of the Business Delegates is:
Use a Business Delegate to encapsulate access to a business service. The Business Delegate hides the implementation
details of the business service, such as lookup and access mechanisms.
.
So, a Business Delegate is a Business Tier Pattern that resides in the client tier.
If you have business services implemented as Session Bean, the Business Delegates will be an abstraction of this Session Bean in the client tier.

I really recommend that you read "Core J2EE Patterns" to clarify those points.

Benoît

SCJP5 | SCBCD5 | SCEA5 Part 1
Muhammad Ahsan Jamshaid
Ranch Hand

Joined: Jun 01, 2006
Posts: 59
Hello Benoît de Chateauvieux,
Thank you for replying, Your reply of point 1.
DAO can be implemented with Stateless Session Bean or POJO.
made me to conculde that session Bean can be used as both, the implementation of session facade pattern and Dao Pattern.

Implementing Dao with pojo sounds good but i am wondoring is there any special benefit of using statless Session Bean as DAO then POJO. i guess POJO will be quite simpler for me.

Thanks you,
J J Wright
Ranch Hand

Joined: Jul 02, 2008
Posts: 254
If you're using the EJB 3 programming model your stateless session beans are POJOs. That's one of the key benefits of EJB 3.

If you want to take advantage of container services like transactions and security, to name but a couple, you can use annotations, and/or the ejb-jar.xml deployment descriptor, to deploy your POJOs as stateless session beans.

Issues like these are at the very heart of J2EE. I think you really need to read the relevant sections in the EJB specification to understand what stateless session beans are. If you want to use stateless session beans to manage access to your persistent entities then I suggest you also look through the JPA sections of the EJB specification, particularly those related to persistent contexts.


SCJP, SCWCD, SCBCD, SCEA 5
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session beans and Dao
 
Similar Threads
Who didn't use SLSB for DAO?
Cleared Part II/III...99%
Cade component diagram and DAO
Can I not use Entity Bean in the part II
DAO with Struts doubt