Examples of SqlParameterSource


Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

    public int updateFileCurrent(FileCurrent fileCurrent) {
        String sql = "update config_file_current " +
                "set version=:version, xml=:xml, comment=:comment, creator=:creator, create_time=:createTime, " +
                "last_publish_version=:lastPublishVersion, last_publisher=:lastPublisher, last_publish_time=:lastPublishTime" +
                " where app_name=:appName and file_name=:fileName";
        SqlParameterSource bpsp = new BeanPropertySqlParameterSource(fileCurrent);
        return getNamedParameterJdbcTemplate().update(sql, bpsp);
    }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

      List<T> dataList = dbTable.getTableData();
      if(null == dataList || dataList.size() < 1) return;
      Map<String, String> idMap = new HashMap<String, String>();
      String id = "";
      String countSql = "";
      SqlParameterSource sqlParameterSource;
      List<Map<String, Object>> idList = new ArrayList<Map<String,Object>>();
      for (T t : dataList) {
        ReflectHelper reflectHelper = new ReflectHelper(t);
        List<String> ignores = new ArrayList<String>();
        ignores.add("class");
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

  }
  public Object executeSqlReturnKey(final String sql, Map<String, Object> param) {
    Object keyValue = null;
    try{
      KeyHolder keyHolder = new GeneratedKeyHolder();
      SqlParameterSource sqlp  = new MapSqlParameterSource(param);
      this.namedParameterJdbcTemplate.update(sql,sqlp, keyHolder);
      keyValue = keyHolder.getKey().longValue();
    }catch (Exception e) {
      keyValue = null;
    }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

  public int updateObject(String sql, Object object) throws DataAccessException {
    if (debug) {
      logger.info("sql:" + sql);
      logger.info("object:" + object);
    }
    SqlParameterSource namedParam = new BeanPropertySqlParameterSource(object);
    KeyHolder keyHolder = new GeneratedKeyHolder();
    int ret = getNameParameterJdbcTemplate().update(sql, namedParam, keyHolder);
    if (ret <= 0)
      return ret;
    try {
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

    assertEquals(666, result);
  }

  @Test
  public void testQueryForIntWitSqlParameterSource() {
    SqlParameterSource args = new MapSqlParameterSource().addValue("id", 24).addValue("xy", "foo");
    given(namedParameterOperations.queryForInt(SQL, args)).willReturn(666);
    int result = namedParameterTemplate.queryForInt(SQL, args);
    assertEquals(666, result);
  }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

  * @throws DataAccessException
  */
  public int insertUser(User user) throws DataAccessException{
     String sql = "insert into bu_user(user_name,password,position_num,add_user,add_time,last_login,del,nickname) "
        + "values (:userName,password(:password),:positionNum,:addUser,now(),now(),0,:nickName)";
     SqlParameterSource paramMap = new BeanPropertySqlParameterSource(user);
    return namedParameterJdbcTemplate.update(sql, paramMap);
   }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

   * @return
   */
  @TriggersRemove(cacheName = "codeCache", removeAll = true)
  public int insertCode(Code code) {
    String sql = "insert into sys_code(group_name,`key`,`value`,parent_key,last_modify) values (:groupName,:key,:value,:parentKey,now())";
    SqlParameterSource paramMap = new BeanPropertySqlParameterSource(code);
    return namedParameterJdbcTemplate.update(sql, paramMap);
  }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

   * @return
   * @throws DataAccessException
   */
  public int deleteUser(String userName) throws DataAccessException {
    String sql = "update bu_user set del = 1 where user_name = :userName";
    SqlParameterSource paramMap = new MapSqlParameterSource("userName", userName);
    return namedParameterJdbcTemplate.update(sql, paramMap);
  }
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

        + " where bu_user.del = 0 and  bu_user.user_name = :userName and "
        + "bu_user.password = password(:password)";
    Map<String, String> map = new HashMap<String, String>();
    map.put("userName", userName);
    map.put("password", password);
    SqlParameterSource paramMap = new MapSqlParameterSource(map);
    RowMapper<User> mapper = new UserMapper();
    try{
      return (User) namedParameterJdbcTemplate.queryForObject(sql, paramMap, mapper);
    }catch (EmptyResultDataAccessException e){
      return null;
View Full Code Here

Examples of org.springframework.jdbc.core.namedparam.SqlParameterSource

   * @param userName
   * @return
   */
  public int deleteUserComplete(String userName) {
    String sql = "delete from bu_user where user_name = :userName";
    SqlParameterSource paramMap = new MapSqlParameterSource("userName", userName);
    return namedParameterJdbcTemplate.update(sql, paramMap);
  }
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.