Package org.hibernate.classic

Examples of org.hibernate.classic.Session


    sessionMap.put( factory, session );
  }

  private static Session doUnbind(SessionFactory factory, boolean releaseMapIfEmpty) {
    Map sessionMap = sessionMap();
    Session session = null;
    if ( sessionMap != null ) {
      session = ( Session ) sessionMap.remove( factory );
      if ( releaseMapIfEmpty && sessionMap.isEmpty() ) {
        context.set( null );
      }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  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
View Full Code Here

    return factory.getSettings().getConnectionReleaseMode();
  }

  protected Session wrap(Session session) {
    TransactionProtectionWrapper wrapper = new TransactionProtectionWrapper( session );
    Session wrapped = ( Session ) Proxy.newProxyInstance(
        Session.class.getClassLoader(),
            SESS_PROXY_INTERFACES,
            wrapper
      );
    // yick!  need this for proper serialization/deserialization handling...
View Full Code Here

    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }

  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 );
      }
    }
View Full Code Here

    sessionMap.put( factory, session );
  }

  private static Session doUnbind(SessionFactory factory, boolean releaseMapIfEmpty) {
    Map sessionMap = sessionMap();
    Session session = null;
    if ( sessionMap != null ) {
      session = ( Session ) sessionMap.remove( factory );
      if ( releaseMapIfEmpty && sessionMap.isEmpty() ) {
        context.set( null );
      }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  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
View Full Code Here

    return factory.getSettings().getConnectionReleaseMode();
  }

  protected Session wrap(Session session) {
    TransactionProtectionWrapper wrapper = new TransactionProtectionWrapper( session );
    Session wrapped = ( Session ) Proxy.newProxyInstance(
        Session.class.getClassLoader(),
        SESSION_PROXY_INTERFACES,
            wrapper
      );
    // yick!  need this for proper serialization/deserialization handling...
View Full Code Here

    cleanupAnyOrphanedSession( factory );
    doBind( session, factory );
  }

  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 );
      }
    }
View Full Code Here

    sessionMap.put( factory, session );
  }

  private static Session doUnbind(SessionFactory factory, boolean releaseMapIfEmpty) {
    Map sessionMap = sessionMap();
    Session session = null;
    if ( sessionMap != null ) {
      session = ( Session ) sessionMap.remove( factory );
      if ( releaseMapIfEmpty && sessionMap.isEmpty() ) {
        context.set( null );
      }
View Full Code Here

      ServletRequest request,
      ServletResponse response,
      FilterChain chain) throws IOException, ServletException {
    log.trace( "===> opening session for request [" + request.hashCode() + "]" );
    // Start the session to be used for this request
    Session session = HibernateUtil.getSessionFactory().openSession();

    try {
      // make the session available to the session factory's "current context"
      ManagedSessionContext.bind( session );

      // pass control along to the rest of the processing chain
      chain.doFilter( request, response );
    }
    finally {
      log.trace( "===> cleaning-up session for request [" + request.hashCode() + "]" );
      // remove session from "current context"
      ManagedSessionContext.unbind( HibernateUtil.getSessionFactory() );

      try {
        session.close();
      }
      catch( Throwable t ) {
        log.warn( "was unable to properly close session for request [" + request.hashCode() + "]" );
      }
    }
View Full Code Here

TOP

Related Classes of org.hibernate.classic.Session

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.