001    /*****************************************************************************
002     * Copyright (c) PicoContainer Organization. All rights reserved.            *
003     * ------------------------------------------------------------------------- *
004     * The software in this package is published under the terms of the BSD      *
005     * style license a copy of which has been included with this distribution in *
006     * the license.html file.                                                    *
007     *                                                                           *
008     * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant   *
009     *****************************************************************************/
010    package org.nanocontainer.persistence.hibernate.classic;
011    
012    import net.sf.hibernate.HibernateException;
013    import net.sf.hibernate.Session;
014    
015    /**
016     * implementors provide session session  management.
017     *
018     * @author Konstantin Pribluda ( konstantin.pribluda[at]infodesire.com )
019     * @version $Revision: 2043 $
020     */
021    public interface SessionProvider {
022    
023        /**
024         * provide hibernate session out of factory create new one if necessary,
025         *
026         * @return The Session value
027         * @throws HibernateException Description of Exception
028         */
029        Session getSession() throws HibernateException;
030    
031    
032        /**
033         * commit transaction currently underway, and start new one ( as side effect
034         * hibernate session will be flushed )
035         */
036        void commit() throws HibernateException;
037    
038        /**
039         * rollback active transaction if any was started. transaction will be reset
040         *
041         * @throws HibernateException if transaction can not be rolled back
042         */
043        void rollback() throws HibernateException;
044    
045        /**
046         * normal session close.  commit transaction is any
047         */
048        void close() throws HibernateException;
049    
050        /**
051         * reset and clean up everything. shall be used is something went
052         * wrong ( for example you received hibernate exception )
053         */
054        void reset();
055    
056    }