com.jfinal.plugin.activerecord.Db.update()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(226)

本文整理了Java中com.jfinal.plugin.activerecord.Db.update()方法的一些代码示例,展示了Db.update()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Db.update()方法的具体详情如下:
包路径:com.jfinal.plugin.activerecord.Db
类名称:Db
方法名:update

Db.update介绍

[英]Execute sql update
[中]执行sql更新

代码示例

代码示例来源:origin: jfinal/jfinal

public static int update(Connection conn, String sql, Object... paras) throws SQLException {
  return Db.update(DbKit.config, conn, sql, paras);
}

代码示例来源:origin: JpressProjects/jpress

@Override
  public void run() {
    if (countsMap.isEmpty()) {
      return;
    }

    Map<Long, AtomicLong> articleViews = new HashMap<>(countsMap);
    countsMap.clear();

    for (Map.Entry<Long, AtomicLong> entry : articleViews.entrySet()) {
      Db.update("update article set view_count = view_count + "
          + entry.getValue().get()
          + " where id = ? ", entry.getKey());
    }
  }
}

代码示例来源:origin: JpressProjects/jpress

@Override
  public void run() {
    if (countsMap.isEmpty()) {
      return;
    }

    Map<Long, AtomicLong> pageViews = new HashMap<>(countsMap);
    countsMap.clear();

    for (Map.Entry<Long, AtomicLong> entry : pageViews.entrySet()) {
      Db.update("update single_page set view_count = view_count + "
          + entry.getValue().get()
          + " where id = ? ", entry.getKey());
    }
  }
}

代码示例来源:origin: JpressProjects/jpress

@Override
  public void run() {
    if (countsMap.isEmpty()) {
      return;
    }

    Map<Long, AtomicLong> articleViews = new HashMap<>(countsMap);
    countsMap.clear();

    for (Map.Entry<Long, AtomicLong> entry : articleViews.entrySet()) {
      Db.update("update article set comment_count = comment_count + "
          + entry.getValue().get()
          + " where id = ? ", entry.getKey());
    }
  }
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean deleteByIds(Object... ids) {
  return Db.update("delete from user where id in  " + SqlUtils.buildInSqlPara(ids)) > 0;
}

代码示例来源:origin: JpressProjects/jpress

@Override
  public void run() {
    if (countsMap.isEmpty()) {
      return;
    }

    Map<Long, AtomicLong> articleViews = new HashMap<>(countsMap);
    countsMap.clear();

    for (Map.Entry<Long, AtomicLong> entry : articleViews.entrySet()) {
      Db.update("update article_comment set reply_count = reply_count + "
          + entry.getValue().get()
          + " where id = ? ", entry.getKey());
    }
  }
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean deleteById(Object id) {
  Db.update("delete from article_category_mapping where category_id = ?", id);
  return super.deleteById(id);
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean deleteByIds(Object... ids) {
  return Db.update("delete from wechat_reply where id in  " + SqlUtils.buildInSqlPara(ids)) > 0;
}

代码示例来源:origin: jfinal/jfinal

public static int update(String configName, Connection conn, String sql, Object... paras) throws SQLException {
  return Db.update(DbKit.getConfig(configName), conn, sql, paras);
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean deleteByIds(Object... ids) {
  return Db.update("delete from single_page where id in  " + SqlUtils.buildInSqlPara(ids)) > 0;
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean batchChangeStatusByIds(String status, Object... ids) {
  return Db.update("update article_comment SET `status` = ? where id in  " + SqlUtils.buildInSqlPara(ids), status) > 0;
}

代码示例来源:origin: JpressProjects/jpress

@Override
@CacheEvict(name = "user_role", key = "*")
public boolean deleteById(Object id) {
  return Db.tx(() -> {
    Db.update("delete from user_role_mapping where role_id = ? ", id);
    Db.update("delete from role_permission_mapping where role_id = ? ", id);
    return RoleServiceProvider.super.deleteById(id);
  });
}

代码示例来源:origin: JpressProjects/jpress

@Override
@CacheEvict(name = "user_role", key = "*")
public boolean deleteByIds(Object... ids) {
  return Db.tx(() -> {
    Db.update("delete from user_role_mapping where role_id in  " + SqlUtils.buildInSqlPara(ids));
    Db.update("delete from role_permission_mapping where role_id in  " + SqlUtils.buildInSqlPara(ids));
    return Db.update("delete from role where id in " + SqlUtils.buildInSqlPara(ids)) > 0;
  });
}

代码示例来源:origin: JpressProjects/jpress

@Override
public boolean deleteById(Object id) {
  return Db.tx(() -> {
    boolean delOk = ArticleServiceProvider.super.deleteById(id);
    if (delOk == false) {
      return false;
    }
    List<Record> records = Db.find("select * from article_category_mapping where article_id = ? ", id);
    if (records == null || records.isEmpty()) {
      return true;
    }
    Db.update("delete from article_category_mapping where article_id = ?", id);
    records.stream().forEach(record -> {
      categoryService.updateCount(record.get("category_id"));
    });
    return true;
  });
}

代码示例来源:origin: JpressProjects/jpress

@Override
public void doUpdateCategorys(long articleId, Long[] categoryIds) {
  Db.tx(() -> {
    Db.update("delete from article_category_mapping where article_id = ?", articleId);
    if (categoryIds != null && categoryIds.length > 0) {
      List<Record> records = new ArrayList<>();
      for (long categoryId : categoryIds) {
        Record record = new Record();
        record.set("article_id", articleId);
        record.set("category_id", categoryId);
        records.add(record);
      }
      Db.batchSave("article_category_mapping", records, records.size());
    }
    return true;
  });
}

代码示例来源:origin: JpressProjects/jpress

public void initWebRole() {
  Role role = new Role();
  role.setId(1l);
  role.setName("默认角色");
  role.setDescription("这个是系统自动创建的默认角色");
  role.setFlag(Role.ADMIN_FLAG);
  role.setCreated(new Date());
  role.setModified(new Date());
  role.save();
  Db.update("INSERT INTO `user_role_mapping` (`user_id`, `role_id`) VALUES (1, 1);");
}

代码示例来源:origin: jfinal/jfinal

private boolean deleteById(Table table, Object... idValues) {
  Config config = _getConfig();
  Connection conn = null;
  try {
    conn = config.getConnection();
    String sql = config.dialect.forModelDeleteById(table);
    return Db.update(config, conn, sql, idValues) >= 1;
  } catch (Exception e) {
    throw new ActiveRecordException(e);
  } finally {
    config.close(conn);
  }
}

代码示例来源:origin: jfinal/jfinal

try {
  conn = config.getConnection();
  int result = Db.update(config, conn, sql.toString(), paras.toArray());
  if (result >= 1) {
    _getModifyFlag().clear();

代码示例来源:origin: bluemapleman/NewsRecommendSystem

public void databaseReady() {
    Db.update("update news set news_time=?",new Date());
    for(int id=1;id<8;id++) {
      Db.update("update users set latest_log_time=? where id=?",RecommendKit.getInRecTimestamp(25+id),id);
    }
    Db.update("update newslogs set view_time=?",new Date());
    
    
  }
}

代码示例来源:origin: yjjdick/sdb-mall

@Override
@JFinalTx
public void updateValueByKey(String key, String value) {
  SqlPara sqlPara = Db.getSqlPara("sysConfig.updateValueByKey", Kv.by("paramValue", value).set("paramKey", key));
  Db.update(sqlPara);
  sysConfigRedis.delete(key);
}

相关文章