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

[2169 byte] By [fmarchioniscreena] at [2007-10-3 7:45:37]
# 1
in the service object. i believe in your case that's the stateless session bean.it's the service that knows about the unit of work and transaction boundaries, not business objects.%
duffymoa at 2007-7-15 2:47:00 > top of Java-index,Other Topics,Patterns & OO Design...