Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using session Beans with persistence Layer

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice explanation Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic