Examples of autoClose()


Examples of jodd.db.oom.DbOomQuery.autoClose()

  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);
  }

  /**
   * Finds previous question of current one.
   * Returns <code>null</code> if there is no previous question.
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

  public Question findPreviousQuestion(Question q) {
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} where $q.date < :date order by $q.date desc limit 0,1"));
    dbOom.setMaxRows(1);
    dbOom.setFetchSize(1);
    dbOom.setInteger("date", q.getDate());
    return dbOom.autoClose().find(Question.class);
  }

  /**
   * Returns list of previous questions.
   */
 
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

   */
  public List<Question> findPreviousQuestions(Question q, int howMany) {
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} where $q.date < :date order by $q.date desc limit 0,:howMany"));
    dbOom.setInteger("date", q.getDate());
    dbOom.setInteger("howMany", howMany);
    return dbOom.autoClose().list(Question.class);
  }

  /**
   * Finds random question from the past.
   */
 
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

  public Question findRandomPastQuestion(JDateTime untilDate) {
    DbOomQuery dbOom = query(sql("select $C{q.*} from $T{Question q} where $q.date < :date order by rand() limit 1"));
    dbOom.setMaxRows(1);
    dbOom.setFetchSize(1)
    dbOom.setInteger("date", DateUtil.toIntDate(untilDate));
    return dbOom.autoClose().find(Question.class);
  }

  /**
   * Finds question for given answer.
   */
 
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

   */
  public Answer findUserAnswerForQuestion(User user, Question question) {
    DbOomQuery dbOom = query(sql("select $C{a.*} from $T{Answer a} join $T{Vote v} on $v.answerId=$a.id where $v.userId=:userId and $a.questionId=:questionId"));
    dbOom.setLong("userId", user.getId());
    dbOom.setLong("questionId", question.getId());
    return dbOom.autoClose().find(Answer.class);
  }

  /**
   * Finds answer by vote id.
   */
 
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

   */
  public void updateAnswerVoteCount(Answer answer, boolean increment) {
    char operation = increment ? '+' : '-';
    DbOomQuery dbOom = query(sql("update $T{Answer a} set $a.votes = $a.votes " + operation + " 1 where $a.id = :id"));
    dbOom.setLong(1, answer.getId());
    dbOom.autoClose().executeUpdate();
    if (increment) {
      answer.incrementVotes();
    } else {
      answer.decrementVotes();
    }
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

   */
  public Vote findUserVoteForQuestion(User user, Question question) {
    DbOomQuery dbOom = query(sql("select $C{v.*} from $T{Vote v} join $T{Answer a} on $v.answerId=$a.id where $v.userId=:userId and $a.questionId=:questionId"));
    dbOom.setLong("userId", user.getId());
    dbOom.setLong("questionId", question.getId());
    return dbOom.autoClose().find(Vote.class);
  }


  /**
   * Votes for answer.
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

   * Counts user votes.
   */
  public long countUserVotes(User user) {
    DbOomQuery dbOom = query(sql("select count(1) from $T{Vote v} where $v.userId = :userId"));
    dbOom.setInteger("userId", user.getId());
    return dbOom.autoClose().executeCount();
  }

}
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

    q.setInteger(1, maxRepeatsOnError);
    if (returnAll == false) {
      q.setInteger(2, maxEmailsPerSession);
    }

    return q.autoClose().list(EmailMessage.class);
  }


  /**
   * Counts all email messages.
View Full Code Here

Examples of jodd.db.oom.DbOomQuery.autoClose()

  /**
   * Counts all email messages.
   */
  public long countEmails() {
    DbOomQuery q = query(sql("select count(1) from $T{EmailMessage email}"));
    return q.autoClose().executeCount();
  }

  /**
   * Counts pending messages.
   */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.