View Javadoc

    1   /***
    2    * @(#)HibernateService.java
    3    *
    4    * JFoxSOAF, Service-Oriented Application Framework
    5    *
    6    * Copyright(c) JFoxSOAF Team
    7    *
    8    * Licensed under the GNU LGPL, Version 2.1 (the "License");
    9    * you may not use this file except in compliance with the License.
    10   * You may obtain a copy of the License at
    11   *
    12   * http://www.gnu.org/copyleft/lesser.html
    13   *
    14   * Unless required by applicable law or agreed to in writing, software
    15   * distributed under the License is distributed on an "AS IS" BASIS,
    16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    17   * See the License for the specific language governing permissions and
    18   * limitations under the License.
    19   *
    20   * For more information, please visit:
    21   * http://www.jfox.cn/confluence/display/JFoxSOAF/Home
    22   * http://www.huihoo.org/jfox/jfoxsoaf
    23   */
    24
    25  package org.huihoo.jfox.soaf.services.persistence;
    26
    27  import net.sf.hibernate.HibernateException;
    28  import net.sf.hibernate.Session;
    29  import net.sf.hibernate.SessionFactory;
    30  import net.sf.hibernate.cfg.Configuration;
    31
    32  /***
    33   * <p>
    34   * Hibernate persistence service, Wrapper service for hibernate.
    35   * </p>
    36   *
    37   * @author <a href="mailto:founder_chen@yahoo.com.cn">Peter Cheng </a>
    38   * @version $Revision: 1.5 $ $Date: 2005/05/22 06:50:29 $
    39   * @version Revision: 1.0
    40   */
    41
    42  public interface HibernateService {
    43
    44      /***
    45       * Create database connection and open a Session on it.
    46       *
    47       * @return a Hibernate Session object
    48       */
    49      public Session openSession() throws HibernateException;
    50
    51      /***
    52       * Return hibernate configuration.
    53       *
    54       * @return a Hibernate Configuration object
    55       */
    56      public Configuration getConfiguration() throws HibernateException;
    57
    58      /***
    59       * Create SessionFactory.
    60       *
    61       * @return a Hibernate SessionFactory object
    62       */
    63      public SessionFactory getSessionFactory() throws HibernateException;
    64
    65      /***
    66       * commit transaction currently underway, and start new one ( as side effect
    67       * hibernate session will be flushed )
    68       */
    69      public void commit() throws HibernateException;
    70
    71      /***
    72       * rollback active transaction if any was started. transaction will be reset
    73       *
    74       * @throws HibernateException if transaction can not be rolled back
    75       */
    76      public void rollback() throws HibernateException;
    77
    78      /***
    79       * normal session close. commit transaction is any
    80       */
    81      public void closeSession() throws HibernateException;
    82
    83      /***
    84       * reset and clean up everything. shall be used is something went wrong (
    85       * for example you received hibernate exception )
    86       */
    87      public void reset();
    88
    89  }