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.
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.
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?
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