Public feed #887348

Mine

public text v1 · immutable
Raw Edit
·published 2008-02-01 07:36 UTC
rendered paste body
        // initialize hibernate session
        SessionFactory sf = 
            (SessionFactory) getApplicationContext().getBean("hibernateFactory");
        // open the session in case we need lazy loading
        Session session = sf.openSession();
        session.setFlushMode(FlushMode.AUTO);
        SessionHolder holder = new SessionHolder(session);
        TransactionSynchronizationManager.bindResource(sf, holder);
        
        injectAuthentication(userId.toString());
        
        // do the actual work
        executeWorkflowAction(articleWorkflow, redaxService, context);
        
        // flush and close hibernate session
        if (session != null) {
            if (session.isDirty()) {
                session.flush();
            }
            TransactionSynchronizationManager.unbindResource(sf);
            SessionFactoryUtils.releaseSession(session, sf);
        }