Where should you acquire the DAO class?
Hi all,
I'm implementing the DAO pattern to interface my Session Beans with the DB.
import java.rmi.*;
import javax.ejb.*;
import java.util.List;
import java.util.*;
publicclass FlightBeanimplements SessionBean{
SessionContext sessionContext;
publicvoid ejbCreate(){
}
publicvoid ejbRemove(){
}
publicvoid ejbActivate(){
}
publicvoid ejbPassivate(){
}
publicvoid setSessionContext(SessionContext sessionContext){
this.sessionContext = sessionContext;
}
public List searchFlights(String field1,String field2){
// create the required DAO Factory
DAOFactory oracleFactory =
DAOFactory.getDAOFactory(DAOFactory.ORACLE);
SearchProcessorDAO searchDAO = oracleFactory.getSearchProcessorDAO();
List array = searchDAO.searchFlights(field1,field2);
return array;
}
}
Is it correct to istantiate the DAO factory and DAO class inside the Session Bean ? or it should be placed somewhere else ?(for example in the Business Delegate Object)
Thanks
Francesco

