• 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

Can session beans update database?

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't there situations where you would coded persistence in Session beans, instead of having entity beans??? What are drawbacks?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would be careful not to put too much responsibility into the EJB (business logic or database access, not both).
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually you can use JDBC dirrectly from the session beans and sometimes it's even better to use it instead of entity beans. This is a design pattern called "JDBC for reading". Let me tell you more about this.
When you wanna be able to insert/update/delete data in/from a table inside a database, you should use entity beans(CMPs). But when all you have to do is read data from the database and display it to the user or do some other simple operations that do not require all the advantages CMPs bring, you can use Session Beans with JDBC and it would be faster than using CMPs.
You can find more about EJBs and EJB Design Patterns in these books: "EJB second edition" by Ed Roman and "EJB Design Patterns" by Floyd Marinescu. You can download both books from http://www.middleware-company.com/ in electronic form.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another case when I use Session Beans with JDBC is with Session Block id generator. Or when creating some views inside a database and you can read data from this views only through dirrect JDBC. Using CMP with views is impossible for the moment and using BMPs is risky.So this is the only solution.
If you want more help you should post the situation you are facing and we all will try to find the best solution for it.
Sergiu.
 
Jean Miles
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for everyone's input.
 
reply
    Bookmark Topic Watch Topic
  • New Topic