Examples of RowMapper


Examples of org.springframework.jdbc.core.RowMapper

    sql.append(" LEFT JOIN parttable as p ON a.partcode = p.partcode ");
    sql.append(" LEFT JOIN emptable as e ON a.empcode = e.empcode ");
    sql.append(" LEFT JOIN roletable as r ON a.rolecode = r.rolecode ");
    sql.append(" WHERE a.defid = ? ");
   
    return this.jdbcTemplate.query(sql.toString(), new Object[] { defId }, new RowMapper() {
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
        Authority authority = new Authority();
       
        authority.setAclid(rs.getString("acltableid"));
        authority.setComcode(rs.getString("comcode"));
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    }
    if ("MYSQL".equals(typeOfDBMS)) {
      sb.append("  limit ").append(listLength);
    }
   
    return this.jdbcTemplate.query(sb.toString(), new RowMapper() {
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
        DashboardWorkList dashboardWorklist = new DashboardWorkList();
        dashboardWorklist.setInstId(rs.getInt("instId"));
        dashboardWorklist.setTrcTag(rs.getString("trcTag"));
        dashboardWorklist.setTaskId(rs.getInt("taskId"));
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

   * @return a List of objects, one per row of the ResultSet. Normally all these
   * will be of the same class, although it is possible to use different types.
   */
  public List execute(Object[] params, Map context) throws DataAccessException {
    validateParameters(params);
    RowMapper rowMapper = newRowMapper(params, context);
    return getJdbcTemplate().query(newPreparedStatementCreator(params), rowMapper);
  }
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    validateNamedParameters(paramMap);
    ParsedSql parsedSql = getParsedSql();
    MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
    String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
    Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
    RowMapper rowMapper = newRowMapper(params, context);
     return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
  }
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(mockDataSource);

    MapSqlParameterSource parms = new MapSqlParameterSource();
    parms.addValue("id", new Integer(3));

    Object o = template.queryForObject(sql, parms, new RowMapper() {
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
        return new Integer(rs.getInt(1));
      }
    });
    assertTrue("Correct result type", o instanceof Integer);
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    List customers = jt.query(SELECT_NAMED_PARAMETERS, params, new RowMapper() {
      public Object mapRow(ResultSet rs, int rownum) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
        cust.setForename(rs.getString(COLUMN_NAMES[1]));
        return cust;
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    NamedParameterJdbcTemplate jt = new NamedParameterJdbcTemplate(mockDataSource);
    Map params = new HashMap();
    params.put("id", new SqlParameterValue(Types.DECIMAL, new Integer(1)));
    params.put("country", "UK");
    Customer cust = (Customer) jt.queryForObject(SELECT_NAMED_PARAMETERS, params, new RowMapper() {
      public Object mapRow(ResultSet rs, int rownum) throws SQLException {
        Customer cust = new Customer();
        cust.setId(rs.getInt(COLUMN_NAMES[0]));
        cust.setForename(rs.getString(COLUMN_NAMES[1]));
        return cust;
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    //~ Methods ========================================================================================================

    public ObjectIdentity[] findChildren(ObjectIdentity parentIdentity) {
        Object[] args = {parentIdentity.getIdentifier(), parentIdentity.getJavaType().getName()};
        List objects = jdbcTemplate.query(selectAclObjectWithParent, args,
                new RowMapper() {
                    public Object mapRow(ResultSet rs, int rowNum)
                        throws SQLException {
                        String javaType = rs.getString("class");
                        String identifier = rs.getString("obj_id");
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

    @SuppressWarnings("unchecked")
    protected Object queryForObject(ResultSet rs) throws SQLException {
        Object result = null;
        if (outputClass == null) {
            RowMapper rowMapper = new ColumnMapRowMapper();
            RowMapperResultSetExtractor<Map<String, Object>> mapper = new RowMapperResultSetExtractor<Map<String, Object>>(rowMapper);
            List<Map<String, Object>> data = mapper.extractData(rs);
            if (data.size() > 1) {
                throw new SQLDataException("Query result not unique for outputType=SelectOne. Got " + data.size() " count instead.");
            } else if (data.size() == 1) {
                // Set content depend on number of column from query result
                Map<String, Object> row = data.get(0);
                if (row.size() == 1) {
                    result = row.values().iterator().next();
                } else {
                    result = row;
                }
            }
        } else {
            Class<?> outputClzz = getCamelContext().getClassResolver().resolveClass(outputClass);
            RowMapper rowMapper = new BeanPropertyRowMapper(outputClzz);
            RowMapperResultSetExtractor<?> mapper = new RowMapperResultSetExtractor(rowMapper);
            List<?> data = mapper.extractData(rs);
            if (data.size() > 1) {
                throw new SQLDataException("Query result not unique for outputType=SelectOne. Got " + data.size() " count instead.");
            } else if (data.size() == 1) {
View Full Code Here

Examples of org.springframework.jdbc.core.RowMapper

  }
 
  @SuppressWarnings("unchecked")
  public List<Map<String, Object>> find(String sql, Object[] params) {
   
    RowMapper rowMapper = new RowMapper() {
     
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
       
        MapDataRoller roller = new MapDataRoller();
        Map<String, Object> row = roller.rollSingleRow(rs);
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.