Package org.hibernate

Examples of org.hibernate.StatelessSession


      final boolean wrapInTransaction = wrapInTransaction();
      if ( wrapInTransaction ) {
        TransactionManager transactionManager = getTransactionManager();
        try {
          final Session session;
          final StatelessSession statelessSession;
          if ( sessionAwareRunnable != null ) {
            session = factory.openSession();
            statelessSession = null;
          }
          else {
            session = null;
            statelessSession = factory.openStatelessSession();
          }

          transactionManager.begin();

          if ( sessionAwareRunnable != null ) {
            sessionAwareRunnable.run( session );
          }
          else {
            statelessSessionAwareRunnable.run( statelessSession );
          }

          transactionManager.commit();

          if ( sessionAwareRunnable != null ) {
            session.close();
          }
          else {
            statelessSession.close();
          }
        }
        catch (Throwable e) {
          errorHandler.handleException( log.massIndexerUnexpectedErrorMessage() , e);
          try {
View Full Code Here


    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper(StatelessSession upperSession) throws Exception {
    StatelessSession session = upperSession;
    if (upperSession == null) {
      session = sessionFactory.openStatelessSession();
    }
    try {
      Transaction transaction = Helper.getTransactionAndMarkForJoin( session );
      transaction.begin();
      loadAllIdentifiers( session );
      transaction.commit();
    }
    catch (InterruptedException e) {
      // just quit
      Thread.currentThread().interrupt();
    }
    finally {
      if (upperSession == null) {
        session.close();
      }
    }
  }
View Full Code Here

        StringBuffer query = new StringBuffer();

        query.append("DELETE FROM ").append(getFromClause(schemaName, tableName)).append(" WHERE ").append(columnName)
                .append("=").append("'").append(columnValue).append("'");

        StatelessSession s = getStatelessSession();

        Transaction tx = onBegin();
        onNativeUpdate(query.toString(), null);
        onCommit(tx);
View Full Code Here

        {
            synchronized (sf)
            {
                for (String pu : pus)
                {
                    StatelessSession session = sf.openStatelessSession();
                    if (!pu.equals(getPersistenceUnit()))
                    {
                        Collection<Class<?>> collection = classes.get(pu);
                        for (Class clazz : collection)
                        {
                            EntityMetadata metadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, clazz);
                            try
                            {
                                session.createSQLQuery("Drop table " + metadata.getTableName()).executeUpdate();
                            }
                            catch (Exception e)
                            {
                                // ignore such drops.
                            }
View Full Code Here

    s.save( yourClock );
    s.save( task );
    s.getTransaction().commit();
    s.close();

    StatelessSession ss = sfi().openStatelessSession();
    ss.beginTransaction();
    Task taskRef = ( Task ) ss.createQuery( "from Task t join fetch t.resource join fetch t.user" ).uniqueResult();
    assertTrue( taskRef != null );
    assertTrue( Hibernate.isInitialized( taskRef ) );
    assertTrue( Hibernate.isInitialized( taskRef.getUser() ) );
    assertTrue( Hibernate.isInitialized( taskRef.getResource() ) );
    assertFalse( Hibernate.isInitialized( taskRef.getResource().getOwner() ) );
    ss.getTransaction().commit();
    ss.close();

    cleanup();
  }
View Full Code Here

    }
    log.trace( "finished" );
  }

  private void inTransactionWrapper() {
    StatelessSession session = sessionFactory.openStatelessSession();
    try {
      Transaction transaction = session.beginTransaction();
      loadAllIdentifiers( session );
      transaction.commit();
    } catch (InterruptedException e) {
      // just quit
    }
    finally {
      session.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.StatelessSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.