hibernatedatabasesession.java

来自「STRUTS数据库项目开发宝典」· Java 代码 · 共 47 行

JAVA
47
字号
package org.helpsoft;

import com.finalist.util.log.*;
import org.helpsoft.exception.GenericBusinessException;
import org.helpsoft.servicelocator.*;

/**
 * The <code>DatabaseSessionImpl </code> is used to allow closing of a database session by the client.
 * This way it is possible too keep database sessions open for lazy loading support.

 *
 * @author  cao guangxin  Helpsoft corp.
 * @site www.helpsoft.org or www.relationinfo.com
 * mail:relationinfo@gmail.com
 */
public class HibernateDatabaseSession implements DatabaseSessionService, LocatableService  {
   /**
    * The logger object.
    */
   private static Logger log = LogService.getLogger(HibernateDatabaseSession.class);

   /**
    * Default implementation for the Locatable Service interface.
    */
    public void init() {
    }

   /**
    * Default implementation for the Locatable Service interface.
    */
    public void destroy() {
    }

   /**
    * Close a database session if it is still open.
    *
    */
   public void close() throws GenericBusinessException {
       try {
       org.helpsoft.HibernateSessionHelper.close();
       } catch (Exception e) {
           log.error("Error whil closing the database connection");
           throw new GenericBusinessException(e);
       }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?