Package jodd.db.oom

Examples of jodd.db.oom.DbOomQuery


  /**
   * Increments repeat count.
   */
  public void incrementRepeatCount(EmailMessage emailMessage) {
    DbOomQuery q = query(sql("update $T{EmailMessage email} set $email.repeatCount=:take where $email.id=:id"));
    emailMessage.incrementRepeatCount();
    q.setInteger("take", emailMessage.getRepeatCount());
    q.setLong("id", emailMessage.getId());
    q.autoClose().executeUpdate();
  }
View Full Code Here


  /**
   * Updates repeat count to 0 for all message.
   */
  public void enableAllEmails() {
    DbOomQuery q = query(sql("update $T{EmailMessage email} set $email.repeatCount=0"));
    q.autoClose().executeUpdate();
  }
View Full Code Here

  /**
   * Enables single message for sending.
   */
  public void enableEmail(EmailMessage emailMessage){
    DbOomQuery q = query(sql("update $T{EmailMessage email} set $email.repeatCount=0 where $email.id=:id"));
    q.setLong("id", emailMessage.getId());
    q.autoClose().executeUpdate();
  }
View Full Code Here

  /**
   * Finds user favorites or <code>null</code> if user has not marked question as favorite.
   */
  protected Favorites findUserFavorite(Question question, User user) {
    DbOomQuery dbOom = query(sql("select $C{f.*} from $T{Favorites f} where $f.questionId = :questionId and $f.userId = :userId"));
    dbOom.setLong(1, question.getId());
    dbOom.setLong(2, user.getId());
    return (Favorites) dbOom.autoClose().find();
  }
View Full Code Here

  /**
   * Find favorite question for user.
   */
  public List<Question> findUserFavorites(User user){
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} join $T{Favorites f} on $q.id = $f.questionId where $f.userId = :userId order by $q.date desc"));
    dbOom.setInteger("userId", user.getId());
    return dbOom.autoClose().list(Question.class);
  }
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

    int from = (page - 1) * pageSize;

    String pageSql = buildPageSql(sql, from, pageSize);
    DbSqlBuilder dbsql = sql(pageSql);

    DbOomQuery query = query(dbsql);
    query.setMaxRows(pageSize);
    query.setFetchSize(pageSize);
    query.setMap(params);

    List<T> list = query.list(pageSize, target);
    query.close();

    String countSql = buildCountSql(sql);
    dbsql = sql(countSql);
    query = query(dbsql);
    query.setMap(params);
    long count = query.executeCount();
    query.close();

    return new PageData<T>(page, (int) count, pageSize, list);
  }
View Full Code Here

  public Question findQuestionForDate(int date) {
    if (log.isDebugEnabled()) {
      log.debug("finding question for " + date);
    }
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} where $q.countryId is null and $q.date <= :date order by $q.date desc limit 0,1"));
    dbOom.setMaxRows(1);
    dbOom.setFetchSize(1);
    dbOom.setInteger("date", date);
    return dbOom.autoClose().find(Question.class);
  }
View Full Code Here

  /**
   * Finds next question of current one.
   * Returns <code>null</code> if there is no next question.
   */
  public Question findNextQuestion(Question q) {
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} where $q.date > :date order by $q.date limit 0,1"));
    dbOom.setMaxRows(1);
    dbOom.setFetchSize(1);
    dbOom.setInteger("date", q.getDate());
    return dbOom.autoClose().find(Question.class);
  }
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.