Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

can we insert datas in to the database using stateless bean??

 
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can we insert datas in to the database using stateless bean??
Usually we just use stateless bean for reporting structure from the database.?
If we can insert any info to the database using stateless bean how can it be done??
 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not really good design practice but I don't think any container will prevent you from looking up a data source with JNDI and executing SQL statements from an SLSB.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes it will work. And it's not a bad practice at all IF you consider your stateless session bean to be a Session Facade on top of a Data Access Object. See Core J2EE Patterns for more details.
Kyle
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it really a good practice if you are already using entity beans? I know SBs can be used to read data, but what are the consequences of bypassing the entity beans to write data directly to the db?
And how would this work if you are using CMP and don't have DAOs?
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ajith, I look at it from a different perspective. Instead of asking why I would not use Entity Beans, I ask myself why I WOULD use them. What benefit do Entity Beans themselves bring?
Transactioning? No. That can be done in the Session Facade layer.
Remoteability? No. That can be done in the Session Facade layer.
Security? No. That can be done in the Session Facade layer.
Persistance? Yes, using CMP prevents me from having to write JDBC code.
Therefore, the only benefit that I truly see with Entity Beans is when I use CMP. Therefore, if I plan on not using CMP and instead writing my own Data Access logic (let's face it, CMP is not the most flexible thing when it comes to O/R mapping) then I would go with Session Facade + DAO.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris,
I am not contesting your opinion( or Kyle's ) that session beans can be used to write data.
My point is, if you already have a system written using entity beans, is it wise to bypass the entity bean layer to write data to the tables and what are the costs of doing so.
 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two benefits of using Entity Bean
1) They are portable, to some extent
2) Writing a JDBC code is prevented
But I feel using SQLJ to code data access portion is much more benefical than using entity Ejb. As the SQLJ precompiles produces a jdbc prepared statement with a precompiled and optimized sql.
Am I missing some thing ...
 
Kyle Brown
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, actually some CMP implementations (like WebSphere's) will use SQLJ if you choose. But the biggest advantage you get out of CMPs that hasn't been mentioned is caching. Most CMP implementations have some fairly sophisticated caching mechanisms built into them to reuse instances, and even avoid making SQL calls if the results have already been brought into memory within the transaction.
Kyle
 
Are you okay? You look a little big. Maybe this tiny ad will help:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic