Hi, 

I know this is a bit OT, but here it is: any help is much appreciated.

This relates to the Hibernate Plugin for Struts.. 

How do I get a handle on the SessionFactory that is stored in the ServletContext??  
(From a SessionBean, that is)

The following is a shortened (an uncompiled!) version of how the SessionFactory is 
stored... 

Colm



import org.apache.struts.action.PlugIn;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import java.net.URL;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;

public class HibernatePlugIn implements PlugIn 
{
        public void init(ActionServlet servlet, ModuleConfig config)    throws 
ServletException 
        {
        Configuration configuration = null;
        URL configFileURL = null;
        private SessionFactory factory = null;
        ServletContext context = null;
        
configFileURL = new URL ("/hibernate.cfg.xml");
        
        configuration = (new Configuration()).configure(configFileURL);
        factory = configuration.buildSessionFactory();
                
        context = servlet.getServletContext();
        context.setAttribute(SessionFactory.class.getName(), factory);
        }       
}



**********************************************************************
This message is sent in confidence for the addressee
only.  The contents are not allowed to be disclosed to
anyone other than the addressee.  Unauthorised 
recipients must preserve this confidentiality and should 
please advise the sender immediately of any error in
transmission.
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to