Hi All,
First of all I want to know if it is possible to use a session bean to load and store data from data source? The reason of my doubt is that the data base table will not be used by any body or concurrently by any bean. Then why should i use Entity bean for this simple store and load operation.
The information which will be stored in the data base are recieved from Servlet. Then this session bean will be stateless or stateful sesion bean? And why?
Thanks in advance.
Your suggestions are appriciated.
-
Database intraction using Session Bean (3 messages)
- Posted by: Sam Dek
- Posted on: September 05 2000 11:26 EDT
Threaded Messages (3)
- Database intraction using Session Bean by Pankaj Vij on September 05 2000 14:49 EDT
- Database intraction using Session Bean by Lawrence Manickam on September 05 2000 16:08 EDT
- Database intraction using Session Bean by Pankaj Vij on September 06 2000 08:07 EDT
- Database intraction using Session Bean by Lawrence Manickam on September 05 2000 16:08 EDT
-
Database intraction using Session Bean[ Go to top ]
- Posted by: Pankaj Vij
- Posted on: September 05 2000 14:49 EDT
- in response to Sam Dek
Hi Sam
Its possible to fire JDBC queries on ur datasource object from session beans.
But there are hosts of problems in this approach.
1.You are making ur code tightly coupled to the database structure ; which u want to avoid.
2.Doesnt make for good object oriented design.
3.U have to think about transactions and loading and storing ur data ; which would have been done by the container if u would have wrapped ur BMPs or CMPs in a session bean..be it stateless or statefull.
So the best approach is to wrap ur database access in entity beans and then invoke it from business methods in ur session beans.
Thanks
Pankaj -
Database intraction using Session Bean[ Go to top ]
- Posted by: Lawrence Manickam
- Posted on: September 05 2000 16:08 EDT
- in response to Pankaj Vij
Pankaj,
I saw ur message in this web page.
How can I call Entity bean business methods into my stateless session bean?
How can I call one stateless bean using one more stateless bean?
Thanks
Lawrence -
Database intraction using Session Bean[ Go to top ]
- Posted by: Pankaj Vij
- Posted on: September 06 2000 20:07 EDT
- in response to Lawrence Manickam
Hi Lawrence
U will consider stateless session bean as a normal bean client.U can invoke this beans home using initialcontext(parameters) according to EJB1.0 or put this info in
ejb-ref tag in ejb-jar.xml file (EJB1.1).
Context initCtx = new InitialContext();
Object result = initCtx.lookup("java:comp/env/ejb/SomeHome");
Hope this helps
Pankaj