• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using session Beans with persistence Layer

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nice explanation Cameron McKenzie
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic