Package com.avaje.ebeaninternal.api

Examples of com.avaje.ebeaninternal.api.SpiTransaction


     */
    public Object getCurrentTransaction() {

        TransactionSynchronizationRegistry syncRegistry = getSyncRegistry();
       
        SpiTransaction t = (SpiTransaction)syncRegistry.getResource(EBEAN_TXN_RESOURCE);
        if (t != null){
            // we have already seen this transaction
            return t;
        }
       
        // check current Ebean transaction
        SpiTransaction currentEbeanTransaction = DefaultTransactionThreadLocal.get(serverName);
        if (currentEbeanTransaction != null){
            // NOT expecting this so log WARNING
            String msg = "JTA Transaction - no current txn BUT using current Ebean one "+currentEbeanTransaction.getId();
            logger.warn(msg);
            return currentEbeanTransaction;
        }
       
        UserTransaction ut = getUserTransaction();
View Full Code Here


   * Return the current Transaction for this serverName and Thread.
   */
  public static SpiTransaction get(String serverName) {
    TransactionMap map = local.get();
    State state = map.getState(serverName);
    SpiTransaction t = (state == null) ? null : state.transaction;
    if (map.isEmpty()) {
      local.remove();
    }
    return t;
  }
View Full Code Here

   */
  public void bind() throws SQLException {
   
    sql = meta.getSql(persistRequest);
   
    SpiTransaction t = persistRequest.getTransaction();
    boolean isBatch = t.isBatchThisRequest();

    PreparedStatement pstmt;
    if (isBatch) {
      pstmt = getPstmt(t, sql, persistRequest, false);
    } else {
View Full Code Here

        return;
    }

    sql  = updatePlan.getSql();
   
    SpiTransaction t = persistRequest.getTransaction();
    boolean isBatch = t.isBatchThisRequest();

    PreparedStatement pstmt;
    if (isBatch) {
      pstmt = getPstmt(t, sql, persistRequest, false);
    } else {
View Full Code Here

    Connection c = null;
    try {
      c = dataSource.getConnection();
      long id = transactionCounter.incrementAndGet();

      SpiTransaction t = createTransaction(explicit, c, id);

      // set the default batch mode. This can be on for
      // jdbc drivers that support getGeneratedKeys
      if (defaultBatchMode){
        t.setBatchMode(true);
      }
      if (isolationLevel > -1) {
        c.setTransactionIsolation(isolationLevel);
      }
     
      if (explicit && TXN_LOGGER.isTraceEnabled()) {
        TXN_LOGGER.trace(t.getLogPrefix()+"Begin");
      }
     
      return t;

    } catch (SQLException ex) {
View Full Code Here

    Connection c = null;
    try {
      c = dataSource.getConnection();
      long id = transactionCounter.incrementAndGet();

      SpiTransaction t = createTransaction(false, c, id);
     
      // set the default batch mode. Can be true for
      // jdbc drivers that support getGeneratedKeys
      if (defaultBatchMode){
        t.setBatchMode(true);
      }
     
      return t;
     
    } catch (PersistenceException ex) {
View Full Code Here

  public void end() {
    DefaultTransactionThreadLocal.end(serverName);
  }

  public SpiTransaction get() {
    SpiTransaction t = DefaultTransactionThreadLocal.get(serverName);
    if (t == null || !t.isActive()){
      return null;
    } else {
      return t;
    }
  }
View Full Code Here

    ResetBasicData.reset();

    ResetBasicData.createOrderCustAndOrder("testPc");

    Transaction t = Ebean.beginTransaction();
    SpiTransaction spiTxn = (SpiTransaction) t;
    PersistenceContext pc = spiTxn.getPersistenceContext();

    System.out.println("pc0:" + pc.toString());

    // no orders or customers in the PC
    Assert.assertEquals(0, pc.size(Order.class));
View Full Code Here

    EBasicVer bean = new EBasicVer();
    bean.setName("Please Delete Me");
   
    Ebean.save(bean);
   
    SpiTransaction transaction = (SpiTransaction)Ebean.beginTransaction();
    try {
     
      EBasicVer bean2 = Ebean.find(EBasicVer.class, bean.getId());
      Assert.assertNotSame(bean, bean2);
     
      EBasicVer bean3 = Ebean.find(EBasicVer.class, bean.getId());
      // same instance from PersistenceContext
      Assert.assertSame(bean2, bean3);
     
      Object bean4 = transaction.getPersistenceContext().get(EBasicVer.class, bean.getId());
      Assert.assertSame(bean2, bean4);
     
      Ebean.delete(bean2);

      Object bean5 = transaction.getPersistenceContext().get(EBasicVer.class, bean.getId());
      Assert.assertNull("Bean is deleted from PersistenceContext",bean5);
     
      EBasicVer bean6 = Ebean.find(EBasicVer.class).where().eq("id", bean.getId()).findUnique();
      Assert.assertNull("Bean where id eq is not found "+bean6, bean6);
     
View Full Code Here

    /**
     * Execute the UpdateSql request.
     */
    public int execute(PersistRequestUpdateSql request) {

        SpiTransaction t = request.getTransaction();
       
        boolean batchThisRequest = t.isBatchThisRequest();
       
        PreparedStatement pstmt = null;
        try {
           
          pstmt = bindStmt(request, batchThisRequest);
View Full Code Here

TOP

Related Classes of com.avaje.ebeaninternal.api.SpiTransaction

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.