Package com.avaje.ebean

Examples of com.avaje.ebean.Transaction


  @Test
  public void test() {

    EbeanServer server = Ebean.getServer(null);

    Transaction transaction = server.beginTransaction();
    try {
      transaction.setBatchMode(true);
      transaction.setBatchSize(20);
      for (int i = 0; i < 10000; i++) {
        EBasic dumbModel = new EBasic();
        dumbModel.setName("Hello");
        server.save(dumbModel);
      }
      transaction.commit();

    } finally {
      transaction.end();
    }   

    QueryIterator<EBasic> iterate = server.find(EBasic.class).findIterate();
    iterate.hashCode();
    try {
View Full Code Here


 
  @Transactional(type = TxType.REQUIRES_NEW)
  public void doSomething() {
   
    logger.info("  --- in DummyDao.doSomething() with TxType.REQUIRES_NEW");
    Transaction txn = Ebean.currentTransaction();
    if (txn == null) {
      logger.error("  NO TRANSACTION ??");
    } else {
      logger.info("  --- txn - "+txn)
    }
View Full Code Here

  public void test() throws InterruptedException, ExecutionException {
   

    EbeanServer server = Ebean.getServer(null);

    Transaction transaction = server.beginTransaction();
    try {
      transaction.setBatchMode(true);
      transaction.setBatchSize(20);
      for (int i = 0; i < 87; i++) {
        EBasic dumbModel = new EBasic();
        dumbModel.setName("HelloB0Bi");
        server.save(dumbModel);
      }
      transaction.commit();

    } finally {
      transaction.end();
    }   
   
    @SuppressWarnings("deprecation")
    PagingList<EBasic> pagingList = Ebean.find(EBasic.class)
        .where().like("name", "HelloB0B%")
View Full Code Here

       
        EbeanServer server = Ebean.getServer(null);
       
        inMethodTransaction = server.currentTransaction();
       
        Transaction t = server.createTransaction();
        SqlUpdate u = server.createSqlUpdate("update e_basicver set last_update = last_update+1 where id = ?");
        u.setParameter(1, v.getId());
        int count = server.execute(u, t);
        Assert.assertEquals(1, count);
       
        t.commit();
       
        v.setName("some change");
        try {
            Ebean.save(v);
            // never get here
View Full Code Here

   
    UTDetail detail1 = new UTDetail("one", 12, 30D);
    UTDetail detail2 = new UTDetail("two", 11, 30D);
    UTDetail detail3 = new UTDetail("three", 8, 30D);
   
    Transaction txn = ebeanServer.beginTransaction();
    try {
      txn.setBatchMode(true);
      ebeanServer.save(detail1);
      ebeanServer.save(detail2);
      ebeanServer.save(detail3);
      txn.commit();
     
    } finally {
      txn.end();
    }
   
    List<UTDetail> details = ebeanServer.find(UTDetail.class).findList();
    Assert.assertEquals(3, details.size());
   
View Full Code Here

  public void runScript(boolean expectErrors, String content) {

    StringReader sr = new StringReader(content);
    List<String> statements = parseStatements(sr);

    Transaction t = server.createTransaction();
    try {
      Connection connection = t.getConnection();

      logger.info("Running DDL");

      runStatements(expectErrors, statements, connection);

      logger.info("Running DDL Complete");

      t.commit();

    } catch (Exception e) {
      String msg = "Error: " + e.getMessage();
      throw new PersistenceException(msg, e);
    } finally {
      t.end();
    }
  }
View Full Code Here

  public <T> FutureRowCount<T> findFutureRowCount(Query<T> q, Transaction t) {

    SpiQuery<T> copy = ((SpiQuery<T>) q).copy();
    copy.setFutureFetch(true);

    Transaction newTxn = createTransaction();

    CallableQueryRowCount<T> call = new CallableQueryRowCount<T>(this, copy, newTxn);

    QueryFutureRowCount<T> queryFuture = new QueryFutureRowCount<T>(call);
    backgroundExecutor.execute(queryFuture.getFutureTask());
View Full Code Here

    // it is available for other threads to read while the id query
    // is still executing (we don't need to wait for it to finish)
    List<Object> idList = Collections.synchronizedList(new ArrayList<Object>());
    copy.setIdList(idList);

    Transaction newTxn = createTransaction();

    CallableQueryIds<T> call = new CallableQueryIds<T>(this, copy, newTxn);
    QueryFutureIds<T> queryFuture = new QueryFutureIds<T>(call);

    backgroundExecutor.execute(queryFuture.getFutureTask());
View Full Code Here

        }
      }
    }

    // Create a new transaction solely to execute the findList() at some future time
    Transaction newTxn = createTransaction();
    CallableQueryList<T> call = new CallableQueryList<T>(this, spiQuery, newTxn);
    QueryFutureList<T> queryFuture = new QueryFutureList<T>(call);
    backgroundExecutor.execute(queryFuture.getFutureTask());

    return queryFuture;
View Full Code Here

  public SqlFutureList findFutureList(SqlQuery query, Transaction t) {

    SpiSqlQuery spiQuery = (SpiSqlQuery) query;
    spiQuery.setFutureFetch(true);

    Transaction newTxn = createTransaction();
    CallableSqlQueryList call = new CallableSqlQueryList(this, query, newTxn);

    FutureTask<List<SqlRow>> futureTask = new FutureTask<List<SqlRow>>(call);

    backgroundExecutor.execute(futureTask);
View Full Code Here

TOP

Related Classes of com.avaje.ebean.Transaction

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.