Package jodd.db.oom

Examples of jodd.db.oom.DbOomQuery


  /**
   * Counts pending messages.
   */
  public long countPendingEmails() {
    DbOomQuery q = query(sql("select count(1) from $T{EmailMessage email} where $email.repeatCount < :maxTake"));
    q.setInteger(1, maxRepeatsOnError);
    return q.autoClose().executeCount();
  }
View Full Code Here


      DbEntityDescriptor ded = dbOomManager.lookupType(entityType);
      String tableName = ded.getTableName();
      String idColumn = ded.getIdColumnName();

      DbOomQuery dbOomQuery = query("select max(" + idColumn + ") from " + tableName);

      long lastLong = dbOomQuery.autoClose().executeCount();

      if (log.isDebugEnabled()) {
        log.debug("Last id for " + entityType.getName() + " is " + lastLong);
      }
View Full Code Here

      dbSqlGenerator = parsedSql;
    }

    // db oom query

    DbOomQuery dbOomQuery = query(dbSqlGenerator);

    // parameter names

    String keyName = proxyTargetInfo.targetClass.getName() + "." + proxyTargetInfo.targetMethodName;

    String[] paramNames = methodParamNames.get(keyName);

    if (paramNames == null) {
      paramNames = resolveMethodParameterNames(proxyTargetInfo);
      methodParamNames.put(keyName, paramNames);
    }

    // set SQL parameters

    for (int i = 0; i < paramNames.length; i++) {
      String paramName = paramNames[i];

      dbOomQuery.setObject(paramName, proxyTargetInfo.arguments[i]);
    }

    return dbOomQuery;
  }
View Full Code Here


  private void insertAnswers() {
    DbSession dbSession = AppCore.ref.createDbSession();

    DbOomQuery dbQuery = new DbOomQuery(dbSession, DbSqlBuilder.sql("select $C{q.*} from $T{Question q} order by $q.id"));
    List<Question> questions =  dbQuery.list();
    dbQuery.close();
   
    for(Question q : questions) {

      dbQuery = new DbOomQuery(dbSession, DbSqlBuilder.sql("select $C{a.*} from $T{Answer a} where $a.questionId=:questionId"));
      dbQuery.setLong("questionId", q.getId());
      List<Answer> answers =  dbQuery.list();
      dbQuery.close();
     
      for (Answer a : answers) {
        dbQuery = new DbOomQuery(dbSession, DbEntitySql.updateColumn(a, "votes", Integer.valueOf(MathUtil.randomInt(10, 50))));
        dbQuery.autoClose().executeUpdate();
      }
    }
  }
View Full Code Here

  /**
   * Returns {@link jodd.db.oom.DbOomQuery} instance for more fluent interface.
   *
   */
  public DbOomQuery query() {
    return new DbOomQuery(this);
  }
View Full Code Here

  public DbOomQuery query() {
    return new DbOomQuery(this);
  }

  public DbOomQuery query(DbSession session) {
    return new DbOomQuery(session, this);
  }
View Full Code Here

TOP

Related Classes of jodd.db.oom.DbOomQuery

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.