Examples of DBQuery


Examples of com.manatee.multiple.v2.db.DbQuery

    try{
      if(startCDL.await(15, TimeUnit.SECONDS)){
        //start
       
        try {
          dataList = new DbQuery().querySQL(mulRecordType);
        } catch (SQLException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (InstantiationException e) {
          // TODO Auto-generated catch block
View Full Code Here

Examples of jodd.db.DbQuery

    if (ded == null) {
      throw new DbOomException("Not an entity: " + type);
    }
    if (isPersistent(ded, entity) == false) {
      DbQuery q;
      if (keysGeneratedByDatabase == true) {
        q = query(insert(entity));
        q.setGeneratedKey();
        q.executeUpdate();
        long nextId = q.getGeneratedKey();
        setEntityId(ded, entity, nextId);
      } else {
        long nextId = generateNextId(ded);
        setEntityId(ded, entity, nextId);
        q = query(insert(entity));
        q.executeUpdate();
      }
      q.close();
    } else {
      query(DbEntitySql.updateAll(entity)).autoClose().executeUpdate();
    }
    return entity;
  }
View Full Code Here

Examples of org.apache.empire.db.DBQuery

        // Define the sub query
        DBCommand subCmd = db.createCommand();
        DBColumnExpr MAX_DATE_FROM = T_EDH.C_DATE_FROM.max().as(T_EDH.C_DATE_FROM);
        subCmd.select(T_EDH.C_EMPLOYEE_ID, MAX_DATE_FROM);
        subCmd.groupBy(T_EDH.C_EMPLOYEE_ID);
        DBQuery Q_MAX_DATE = new DBQuery(subCmd);

        // Define the query
        DBCommand cmd = db.createCommand();
        // Select required columns
        cmd.select(T_EMP.C_EMPLOYEE_ID, T_EMP.C_FULLNAME);
        cmd.select(T_EMP.C_GENDER, T_EMP.C_PHONE_NUMBER);
        cmd.select(T_DEP.C_DEPARTMENT_ID, T_DEP.C_NAME, T_DEP.C_BUSINESS_UNIT);
        cmd.select(T_EMP.C_UPDATE_TIMESTAMP, T_DEP.C_UPDATE_TIMESTAMP);
        // Set Joins
        cmd.join(T_EDH.C_EMPLOYEE_ID, Q_MAX_DATE.findQueryColumn(T_EDH.C_EMPLOYEE_ID))
          .where(T_EDH.C_DATE_FROM.is(Q_MAX_DATE.findQueryColumn(MAX_DATE_FROM)));
        cmd.join(T_EMP.C_EMPLOYEE_ID, T_EDH.C_EMPLOYEE_ID);
        cmd.join(T_DEP.C_DEPARTMENT_ID, T_EDH.C_DEPARTMENT_ID);
        // Set Constraints
        cmd.where(T_EMP.C_RETIRED.is(false));
        // Set Order
        cmd.orderBy(T_EMP.C_LASTNAME);
        cmd.orderBy(T_EMP.C_FIRSTNAME);

        // Query Records and print output
        printQueryResults(cmd, conn);
       
        // Define an updateable query
        DBQuery Q_EMP_DEP = new DBQuery(cmd, T_EMP.C_EMPLOYEE_ID);
        DBRecord rec = new DBRecord();
        rec.read(Q_EMP_DEP, employeeId, conn);
        // Modify and Update fields from both Employee and Department
        rec.setValue(T_EMP.C_PHONE_NUMBER, "0815-4711");
        rec.setValue(T_DEP.C_BUSINESS_UNIT, "AUTO");
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

        // then we would run into an ERROR when we'd do more with this DB
        // hence we just issue a log.info here with the details
        //@TODO: lower to log_.info once we checked that it doesn't occur very often (best for 6.4)
        log_.warn("log: DB is in Error state therefore the UserActivityLoggerImpl cannot update the simpleDuration of log_id "+lastLogObj.getKey()+" with value "+duration+", loggingObject: "+lastLogObj);
      } else {
        DBQuery update = DBFactory.getInstance().createQuery(
            "update org.olat.core.logging.activity.LoggingObject set simpleDuration = :duration where log_id = :logid");
        update.setLong("duration", duration);
        update.setLong("logid", lastLogObj.getKey());
        // we have to do FlushMode.AUTO (which is the default anyway)
        update.executeUpdate(FlushMode.AUTO);
      }
    }
   
    // store the current logging object in the session - for duration calculation at next log
    session_.putEntry(USESS_KEY_USER_ACTIVITY_LOGGING_LAST_LOG, logObj);
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#calculateRatingAverage()
   */
  @Override
  public Float calculateRatingAverage() {
    DBQuery query;
    if (getOLATResourceableSubPath() == null) {
      // special query when sub path is null
      query = DBFactory
          .getInstance()
          .createQuery(
              "select avg(rating) from UserRatingImpl where resName=:resname AND resId=:resId AND resSubPath is NULL");
    } else {
      query = DBFactory
          .getInstance()
          .createQuery(
              "select avg(rating) from UserRatingImpl where resName=:resname AND resId=:resId AND resSubPath=:resSubPath");
      query.setString("resSubPath", getOLATResourceableSubPath());
    }
    query.setString("resname", getOLATResourceable()
        .getResourceableTypeName());
    query.setLong("resId", getOLATResourceable().getResourceableId());
    query.setCacheable(true);
    //
    List results = query.list();
    Double average = (Double) query.list().get(0);
    // When no ratings are found, a null value is returned!
    if (average == null) return Float.valueOf(0);
    else return average.floatValue();     
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#countRatings()
   */
  @Override
  public Long countRatings() {
    DBQuery query;
    if (getOLATResourceableSubPath() == null) {
      // special query when sub path is null
      query = DBFactory
          .getInstance()
          .createQuery(
              "select count(*) from UserRatingImpl where resName=:resname AND resId=:resId AND resSubPath is NULL");
    } else {
      query = DBFactory
          .getInstance()
          .createQuery(
              "select count(*) from UserRatingImpl where resName=:resname AND resId=:resId AND resSubPath=:resSubPath");
      query.setString("resSubPath", getOLATResourceableSubPath());
    }
    query.setString("resname", getOLATResourceable()
        .getResourceableTypeName());
    query.setLong("resId", getOLATResourceable().getResourceableId());
    query.setCacheable(true);
    //
    Long count = (Long) query.list().get(0);
    return count;
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

   *
   * @see org.olat.core.commons.services.commentAndRating.UserRatingsManager#getRating(org.olat.core.id.Identity)
   */
  @Override
  public UserRating getRating(Identity identity) {
    DBQuery query;
    if (getOLATResourceableSubPath() == null) {
      // special query when sub path is null
      query = DBFactory
          .getInstance()
          .createQuery(
              "select userRating from UserRatingImpl as userRating where creator=:creator AND resName=:resname AND resId=:resId AND resSubPath is NULL ");
    } else {
      query = DBFactory
          .getInstance()
          .createQuery(
              "select userRating from UserRatingImpl as userRating where creator=:creator AND resName=:resname AND resId=:resId AND resSubPath=:resSubPath");
      query.setString("resSubPath", getOLATResourceableSubPath());
    }
    query.setString("resname", getOLATResourceable()
        .getResourceableTypeName());
    query.setLong("resId", getOLATResourceable().getResourceableId());
    query.setEntity("creator", identity);
    query.setCacheable(true);
    //
    List<UserRating> results = query.list();
    if (results.size() == 0) return null;   
    return results.get(0);
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserCommentsManager#countComments()
   */
  @Override
  public Long countComments() {
    DBQuery query;
    if (getOLATResourceableSubPath() == null) {
      // special query when sub path is null
      query = DBFactory
          .getInstance()
          .createQuery(
              "select count(*) from UserCommentImpl where resName=:resname AND resId=:resId AND resSubPath is NULL");
    } else {
      query = DBFactory
          .getInstance()
          .createQuery(
              "select count(*) from UserCommentImpl where resName=:resname AND resId=:resId AND resSubPath=:resSubPath");
      query.setString("resSubPath", getOLATResourceableSubPath());
    }
    query.setString("resname", getOLATResourceable()
        .getResourceableTypeName());
    query.setLong("resId", getOLATResourceable().getResourceableId());
    query.setCacheable(true);
    //
    Long count = (Long) query.list().get(0);
    return count;
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

  /**
   * @see org.olat.core.commons.services.commentAndRating.UserCommentsManager#getComments()
   */
  @Override
  public List<UserComment> getComments() {
    DBQuery query;
    if (getOLATResourceableSubPath() == null) {
      // special query when sub path is null
      query = DBFactory
          .getInstance()
          .createQuery(
              "select comment from UserCommentImpl as comment where resName=:resname AND resId=:resId AND resSubPath is NULL");
    } else {
      query = DBFactory
          .getInstance()
          .createQuery(
              "select comment from UserCommentImpl as comment where resName=:resname AND resId=:resId AND resSubPath=:resSubPath");
      query.setString("resSubPath", getOLATResourceableSubPath());
    }
    query.setString("resname", getOLATResourceable()
        .getResourceableTypeName());
    query.setLong("resId", getOLATResourceable().getResourceableId());
    query.setCacheable(true);
    //
    List<UserComment> results = query.list();
    return results;
  }
View Full Code Here

Examples of org.olat.core.commons.persistence.DBQuery

      // Original comment has been deleted in the meantime. Don't delete it again.
      return 0;
    }
    DB db = DBFactory.getInstance();
    // First deal with all direct replies
    DBQuery query = db.createQuery("select comment from UserCommentImpl as comment where parent=:parent");
    query.setEntity("parent", comment);
    List<UserComment> replies = query.list();
    if (deleteReplies) {
      // Since we have a many-to-one we first have to recursively delete
      // the replies to prevent foreign key constraints
      for (UserComment reply : replies) {
        counter += deleteComment(reply, true);
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.