aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes using session Beans with persistence Layer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "using session Beans with persistence Layer" Watch "using session Beans with persistence Layer" New topic
Author

using session Beans with persistence Layer

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234


I have seen a lot of people prefer using session Beans with persistence Layer for performing DataBase operations .
Please tell me what are the advantages one will get when using sessionBeans in combination



Thanks in advance.

Save India From Corruption - Anna Hazare.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

I think what we see is a Session EJB calling a Service object, which uses DAOs to update the database. This embraces the various design patterns of Session Facade, Application Service, and Data Access Object. Google these terms along with J2EE design patterns and you'll find some very informative information on Sun's website.

-Cameron McKenzie
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

This embraces the various design patterns of Session Facade, Application Service, and Data Access Object. Google these terms along with J2EE design patterns



session Facade : Here i am not dealing with EntityBeans as a Persistence Layer so session Facade will not come into picture

Data Access Object. : Coming to this , instead of a servlet , a session Bean is calling the DAO Layer (so there is already DAO existing)

Application service : ??


But these pattern does not answer my question
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

If a request comes into a Session Bean, there's coordination that needs to be done. What if you're hitting three database tables? What if a log table is in a separate database? What if it all needs to be done in one transaction? What if it needs to be done in three separate transactions? What happens when the second table write throws an exception? What if there's a message queue involved?

This type of logic goes in an 'application service', which is usually called by the Session Bean. It's the standard service layer, and should be implemented with POJOs.

You might be doing this in your session bean, but that'll make it very difficult to move from EJB 2.x to EJB 3.0.

Web to delegate to session bean to application service to DAO to database and back. That's a pretty standard framework in the J2EE world. Seam and Spring have plenty to say on this topic, but still, that's the meat of many J2EE apps.

-Cameron McKenzie
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

nice explanation Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using session Beans with persistence Layer