⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hibernatetesthelper.java

📁 一个java工作流引擎
💻 JAVA
字号:
package org.jbpm.persistence.hibernate;

import java.util.*;

import org.jbpm.*;
import net.sf.hibernate.*;

/**
 * creates hibernate objects based on the configurations found in 
 * the file core/src/test/config/jbpm.properties.  The
 * created session factory is cached.
 */
public class HibernateTestHelper {
  private static HibernateJdbcSessionFactory hibernateSessionFactory = null;
  private Session session = null;
  private Transaction transaction = null;
	private JbpmConfiguration jbpmConfiguration = null;
  
  public HibernateTestHelper() {
  }
  
  public HibernateTestHelper( JbpmConfiguration jbpmConfiguration ) {
    this.jbpmConfiguration = jbpmConfiguration;
  }
  
  public void startTransaction() throws HibernateException {
    if ( hibernateSessionFactory == null ) {
      if ( jbpmConfiguration == null ) {
        Properties hibernateProperties = TestHelper.getProperties( "jbpm.properties" );
        jbpmConfiguration = new JbpmConfiguration( hibernateProperties );
      }
      hibernateSessionFactory = new HibernateJdbcSessionFactory( jbpmConfiguration );
    }
    session = hibernateSessionFactory.getSessionFactory().openSession();
		transaction = session.beginTransaction();
  }
  
  public void commitTransaction() throws HibernateException {
    session.flush();
    transaction.commit();
    session.close();
  }
  
  public Session getSession() {
    return session; 
  }
}

⌨️ 快捷键说明

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