org.hibernate.classic.Session.getTransaction()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中org.hibernate.classic.Session.getTransaction()方法的一些代码示例,展示了Session.getTransaction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getTransaction()方法的具体详情如下:
包路径:org.hibernate.classic.Session
类名称:Session
方法名:getTransaction

Session.getTransaction介绍

暂无

代码示例

代码示例来源:origin: org.compass-project/compass

protected void doBindSessionToTransaction(CompassTransaction tr, CompassSession session) throws CompassException {
  currentSessionMap.put(sessionFactory.getCurrentSession().getTransaction(), session);
}

代码示例来源:origin: org.jboss.identity.idm/idm-hibernate

public void commitTransaction()
{
 sessionFactory.getCurrentSession().getTransaction().commit();
}

代码示例来源:origin: org.jboss.identity.idm/idm-hibernate

public boolean isTransactionActive()
  {
   return sessionFactory.getCurrentSession().getTransaction().isActive();
  }
}

代码示例来源:origin: org.jboss.identity.idm/idm-hibernate

public void startTransaction()
{
 sessionFactory.getCurrentSession().getTransaction().begin();
}

代码示例来源:origin: org.jboss.identity.idm/idm-hibernate

public void rollbackTransaction()
{
 sessionFactory.getCurrentSession().getTransaction().rollback();
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    // on the inverse, it makes sense that if a ThreadLocalSessionContext-
    // bound session then gets deserialized to go ahead and re-bind it to
    // the ThreadLocalSessionContext session map.
    ois.defaultReadObject();
    realSession.getTransaction().registerSynchronization( buildCleanupSynch() );
    doBind( wrappedSession, factory );
  }
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

private static void cleanupAnyOrphanedSession(SessionFactory factory) {
  Session orphan = doUnbind( factory, false );
  if ( orphan != null ) {
    log.warn( "Already session bound on call to bind(); make sure you clean up your sessions!" );
    try {
      if ( orphan.getTransaction() != null && orphan.getTransaction().isActive() ) {
        try {
          orphan.getTransaction().rollback();
        }
        catch( Throwable t ) {
          log.debug( "Unable to rollback transaction for orphaned session", t );
        }
      }
      orphan.close();
    }
    catch( Throwable t ) {
      log.debug( "Unable to close orphaned session", t );
    }
  }
}

代码示例来源:origin: caelum/caelum-stella

private static void save(Modelo modelo) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    ModeloDAO dao = new ModeloDAO(session);
    try {
      dao.save(modelo);
      System.out.println("Modelo válido: " + modelo);
      session.getTransaction().commit();
    } catch (ConstraintViolationException e) {
      System.out.println("Modelo inválido: " + modelo);
      System.out
          .println("Listagem das mensagens de validação (obtidas do arquivo ValidatorMessages.properties):");
      for (ConstraintViolation<?> violation : e.getConstraintViolations()) {
        System.out.println("\t" + violation.getMessage());
      }
      session.getTransaction().rollback();
    } finally {
      session.close();
    }
  }
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

else if ( !realSession.getTransaction().isActive() ) {

代码示例来源:origin: net.sourceforge.wicketwebbeans.databinder/wicketwebbeans-databinder

public void delete(AjaxRequestTarget target, Form form, Object bean)
{
  // confirm message shown by wwb. If we get here we do a delete
  Session session = DataStaticService.getHibernateSession();
  session.beginTransaction();
  session.delete(bean);
  session.getTransaction().commit();
  if (target != null) // ajax request
    target.addComponent(panel);
}

代码示例来源:origin: org.compass-project/compass

SessionImplementor hibernateSession = ((SessionImplementor) sessionFactory.getCurrentSession());
newTransaction = !hibernateSession.isTransactionInProgress();
transaction = sessionFactory.getCurrentSession().getTransaction();
if (newTransaction) {
  if (log.isDebugEnabled()) {

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public final Session currentSession() throws HibernateException {
  Session current = existingSession( factory );
  if (current == null) {
    current = buildOrObtainSession();
    // register a cleanup synch
    current.getTransaction().registerSynchronization( buildCleanupSynch() );
    // wrap the session in the transaction-protection proxy
    if ( needsWrapping( current ) ) {
      current = wrap( current );
    }
    // then bind it
    doBind( current, factory );
  }
  return current;
}

相关文章