[jboss-user] [JBoss jBPM] - jbpmContext.getSessionFactory().openSession() and jbpmConte

rainhust do-not-reply at jboss.com
Thu Dec 27 21:48:29 EST 2007


Session session = jbpmContext.getSessionFactory().openSession();
  | Transaction tx = session.beginTransaction();
  | 
this's ok!

and i use following code , will get a "Transaction not successfully started" exception.


  | Session session = jbpmContext.getSession();
  | Transaction tx = session.beginTransaction();
  | 

i saw the source code, and in "org.jbpm.persistence.db.DbPersistenceService" class i found:


  |  public Session getSession() {
  |     if ( (session==null)
  |          && (getSessionFactory()!=null) 
  |        ) {
  |       Connection connection = getConnection(false);
  |       if (isCurrentSessionEnabled) {
  |         session = getSessionFactory().getCurrentSession();
  |         log.debug("using current hibernate session " + session);
  |         mustSessionBeClosed = false;
  |         mustSessionBeFlushed = false;
  |         mustConnectionBeClosed = false;
  |       } else if (connection!=null) {
  |         log.debug("creating hibernate session with connection "+connection);
  |         session = getSessionFactory().openSession(connection);
  |         mustSessionBeClosed = true;
  |         mustSessionBeFlushed = true;
  |         mustConnectionBeClosed = false;
  |       } else {
  |         log.debug("creating hibernate session");
  |         session = getSessionFactory().openSession();
  |         mustSessionBeClosed = true;
  |         mustSessionBeFlushed = true;
  |         mustConnectionBeClosed = false;
  |       }
  |       
  |       if (isTransactionEnabled) {
  |         beginTransaction();
  |       }
  |     }
  |     return session;
  |   }

 maybe "isTransactionEnabled" started a transaction,and this cause the exception. 

so ,i want to know where "isTransactionEnabled" can config in jbpm config file.

also you can tell me  jbpmContext.getSessionFactory().openSession() and jbpmContext.getSession() difference, and how to correct using them. 

any advice, thx.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115833#4115833

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115833



More information about the jboss-user mailing list