Package org.springframework.jdbc.core

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


    //~ 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

    @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

  }
 
  @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

  }
 
  @SuppressWarnings("unchecked")
  public <E extends Entity> List<E> find(String sql, Object[] params, final Class<E> clazz) {
   
    RowMapper rowMapper = new RowMapper() {
     
      public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
       
        EntityDataRoller<E> roller = new EntityDataRoller<E>(clazz);
        E e = roller.rollSingleRow(rs);
View Full Code Here

    @SuppressWarnings("unchecked")
    public List<GrantedAuthority> findGroupAuthorities(String groupName) {
        logger.debug("Loading authorities for group '" + groupName + "'");
        Assert.hasText(groupName);

        List<GrantedAuthority> authorities = getJdbcTemplate().query(groupAuthoritiesSql, new String[] {groupName}, new RowMapper() {
            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                 String roleName = getRolePrefix() + rs.getString(3);
                 GrantedAuthorityImpl authority = new GrantedAuthorityImpl(roleName);

                 return authority;
View Full Code Here

                if (statement == null) {
                    StatementMetaData smd = new StatementMetaData(daoMetaData, method);
                    SQLType sqlType = smd.getSQLType();
                    Querier querier;
                    if (sqlType == SQLType.READ) {
                        RowMapper rowMapper = rowMapperFactory.getRowMapper(smd);
                        querier = new SelectQuerier(dataAccessFactory, smd, rowMapper);
                    } else {
                        querier = new UpdateQuerier(dataAccessFactory, smd);
                    }
                    Interpreter[] interpreters = interpreterFactory.getInterpreters(smd);
View Full Code Here

                        "com.alibaba.cobar.client.entities.Follower.load", id);
                assertNotNull(follower);
                assertEquals(name + nameSuffix, follower.getName());
            } else {
                String sql = "select * from followers where name=?";
                RowMapper rowMapper = new RowMapper() {
                    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                        Follower f = new Follower();
                        f.setId(rs.getLong(1));
                        f.setName(rs.getString(2));
                        return f;
View Full Code Here

            {
                followersToUpdate.add(follower);
            }
            else
            {
                follower = (Follower)jt2m.queryForObject("select * from followers where name=?", new Object[]{name}, new RowMapper(){
                    public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                        Follower f = new Follower();
                        f.setId(rs.getLong(1));
                        f.setName(rs.getString(2));
                        return f;
View Full Code Here

        String[] names = { "Aaron", "Amily", "Aragon", "Darren", "Darwin" };
        batchInsertMultipleFollowersAsFixture(names);
       
        for(String name:names)
        {
            Follower f = (Follower)jt1m.queryForObject("select * from followers where name=?",new Object[]{name}, new RowMapper(){
                public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                    Follower fl =  new Follower();
                    fl.setId(rs.getLong(1));
                    fl.setName(rs.getString(2));
                    return fl;
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.RowMapper

Copyright © 2018 www.massapicom. 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.