Package org.activejpa.jpa

Examples of org.activejpa.jpa.JPAContext


    }
    return new EntityCollection<T>(this, name, elementType);
  }
 
  protected static <T> T execute(Executor<T> executor, boolean readOnly) {
    JPAContext context = JPA.instance.getDefaultConfig().getContext();
    boolean beganTxn = false;
    if (! context.isTxnOpen()) {
      context.beginTxn();
      beganTxn = true;
    }
    try {
      return executor.execute(getEntityManager());
    } finally {
      if (beganTxn) {
        context.closeTxn(readOnly);
      }
    }
  }
View Full Code Here


  public void destroy() {
  }

  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    JPAContext context = JPA.instance.getDefaultConfig().getContext();   
    context.getEntityManager();
    logger.debug("Initialized context and transaction");
   
    try {
      logger.debug("Executing ServletRequest");
      chain.doFilter(request, response);
      logger.debug("Done with execution of ServletRequest");
     
    } finally {
      logger.debug("Closing context and transaction");
      if (context.isTxnOpen()) {
        context.closeTxn(true);
      }
      context.close();
      logger.debug("Closed context and transaction");
    }
  }
View Full Code Here

  public Thread newThread(Runnable runnable) {
    return new Thread(runnable) {

      @Override
      public void run() {
        JPAContext context = JPA.instance.getDefaultConfig().getContext();
        context.getEntityManager();
        try {
          super.run();
        } catch(Exception e) {
          e.printStackTrace();
        } finally {
          if (context.isTxnOpen()) {
            context.closeTxn(true);
          }
          context.close();
        }
      }
    };
  }
View Full Code Here

TOP

Related Classes of org.activejpa.jpa.JPAContext

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.