Java 类org.springframework.jdbc.core.RowMapper 实例源码

项目:Learning-Spring-5.0    文件:BookDAO_JdbcTemplate.java   
@Override
public List<Book> findAllBooks(String author) {
    // TODO Auto-generated method stub
    System.out.println(author);
    String FIND_ALL_Author="select * from book where author=?";
    return jdbcTemplate.query(FIND_ALL_Author,new String[]{author}, new RowMapper<Book>() {

        @Override
        public Book mapRow(ResultSet set, int rows) throws SQLException {
            // TODO Auto-generated method stub
            Book book=new Book();
            while(set.next())
            {
                book.setAuthor(set.getString("author"));
                book.setBookName(set.getString("bookName"));
                book.setISBN(set.getLong("ISBN"));
                book.setPublication(set.getString("publication"));
                book.setDescription(set.getString("description"));
            }
            System.out.println(book.getISBN()+"\t"+book.getAuthor());
            return book;

        }
    });
}
项目:spring-data-jdbc    文件:JdbcQueryLookupStrategy.java   
/**
 * Creates a {@link QueryLookupStrategy} for the given {@link EntityManager}
 * and {@link Key}.
 *
 * @param em                        must not be {@literal null}.
 * @param key                       may be {@literal null}.
 * @param extractor                 must not be {@literal null}.
 * @param evaluationContextProvider must not be {@literal null}.
 * @return
 */
public static QueryLookupStrategy create(Key key, EvaluationContextProvider evaluationContextProvider,
                                         SqlGenerator generator, NamedParameterJdbcTemplate template, RowMapper rowMapper,
                                         TableDescription tableDescription) {

    Assert.notNull(evaluationContextProvider, "EvaluationContextProvider must not be null!");

    switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) {
        case CREATE:
            return new CreateQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case USE_DECLARED_QUERY:
            return new DeclaredQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        case CREATE_IF_NOT_FOUND:
            return new CreateIfNotFoundQueryLookupStrategy(generator, template, rowMapper, tableDescription);
        default:
            throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key));
    }
}
项目:bdf2    文件:LobStoreServiceImpl.java   
public Reader getCharacterStream(String id) throws SQLException {
    final String sql = "SELECT CONTENT_ FROM BDF2_CLOB_STORE WHERE ID_=?";
    List<Reader> list = super.getJdbcTemplate().query(sql,
            new Object[] { id }, new RowMapper<Reader>() {

                public Reader mapRow(ResultSet resultset, int i)
                        throws SQLException {
                    Reader content = LobStoreServiceImpl.this
                            .getLobHandler().getClobAsCharacterStream(
                                    resultset, 1);
                    return content;
                }

            });
    if(list.size() > 0){
        return list.get(0);
    }
    return null;
}
项目:bdf2    文件:JdbcDao.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void pagingQuery(Page<?> page,String sql,String dataSourceName,Map<String,Object> parameters,RowMapper<?> mapper){
    NamedParameterJdbcTemplate namedjdbcTemplate=this.getNamedParameterJdbcTemplate(dataSourceName);            
    String querySql=this.getDialect(this.getJdbcTemplate(dataSourceName)).getPaginationSql(sql, page.getPageNo(), page.getPageSize());
    String countSql="select count(*) from ("+sql+") sub_table_alias_";
    if(parameters!=null){
        if(mapper==null){
            page.setEntities((List)namedjdbcTemplate.queryForList(querySql,parameters));
        }else{
            page.setEntities((List)namedjdbcTemplate.query(querySql,parameters,mapper));
        }
        page.setEntityCount(namedjdbcTemplate.queryForObject(countSql,parameters, Integer.class));                              
    }else{
        JdbcTemplate jdbcTemplate=this.getJdbcTemplate(dataSourceName);
        if(mapper==null){
            page.setEntities((List)jdbcTemplate.queryForList(querySql));                
        }else{
            page.setEntities((List)jdbcTemplate.query(querySql,mapper));                                
        }
        page.setEntityCount(jdbcTemplate.queryForObject(countSql, Integer.class));
    }
}
项目:Spring-5.0-Cookbook    文件:EmployeeDaoImpl.java   
@Override
public Employee getEmployee(Integer id) {
    String sql = "SELECT * FROM employee WHERE id = ?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Employee>() {
        @Override
        public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {

            Employee emp = new Employee();

            emp.setId(rs.getInt("id"));
            emp.setEmpId(rs.getInt("empId"));
            emp.setFirstName(rs.getString("firstName"));
            emp.setLastName(rs.getString("lastName"));
            emp.setBirthday(rs.getDate("birthday"));
            emp.setAge(rs.getInt("age"));
            emp.setEmail(rs.getString("email"));
            emp.setDeptId(rs.getInt("deptId"));
            return emp;
        }
    }, id);
}
项目:NGB-master    文件:BookmarkDao.java   
private static RowMapper<Bookmark> getRowMapper() {
    return (rs, rowNum) -> {
        Bookmark bookmark = new Bookmark();

        bookmark.setId(rs.getLong(BOOKMARK_ID.name()));
        bookmark.setName(rs.getString(BOOKMARK_NAME.name()));
        bookmark.setStartIndex(rs.getInt(START_INDEX.name()));
        bookmark.setEndIndex(rs.getInt(END_INDEX.name()));
        bookmark.setChromosome(new Chromosome(rs.getLong(REFERRED_CHROMOSOME_ID.name())));
        bookmark.getChromosome().setName(rs.getString(CHROMOSOME_NAME.name()));
        bookmark.setCreatedBy(rs.getLong(CREATED_BY.name()));
        bookmark.setCreatedDate(new Date(rs.getTimestamp(CREATED_DATE.name()).getTime()));

        return bookmark;
    };
}
项目:Spring-5.0-Cookbook    文件:LoginDaoImpl.java   
@Override
public List<RolePermission> getUserGrantedAuthority(int userId) {
    String sql = "SELECT * FROM role_permission WHERE userId=?";
    List<RolePermission> roleperms = jdbcInsert.getJdbcTemplate().query(sql, new Object[]{userId}, new RowMapper<RolePermission>() {

        @Override
        public RolePermission mapRow(ResultSet rs, int rowNum) throws SQLException {
            RolePermission roleperm = new RolePermission();
            roleperm.setId(rs.getInt("id"));
            roleperm.setRoleId(rs.getInt("roleId"));
            roleperm.setPermissionId(rs.getInt("permissionId"));
            roleperm.setUserId(rs.getInt("userId"));

            return roleperm;
        }
    });
    return roleperms;
}
项目:NGB-master    文件:ProjectDao.java   
@Transactional(propagation = Propagation.MANDATORY)
public Map<Long, List<Project>> loadNestedProjects(List<Long> parentIds) {
    if (CollectionUtils.isEmpty(parentIds)) {
        return Collections.emptyMap();
    }
    long listId = daoHelper.createTempLongList(parentIds);

    Map<Long, List<Project>> map = new HashMap<>();
    RowMapper<Project> rowMapper = ProjectParameters.getRowMapper();
    getJdbcTemplate().query(loadProjectsByParentIdsQuery, rs -> {
        Project project = rowMapper.mapRow(rs, 0);

        long parentId = rs.getLong(ProjectParameters.PARENT_ID.name());
        if (!map.containsKey(parentId)) {
            map.put(parentId, new ArrayList<>());
        }

        map.get(parentId).add(project);
    }, listId);

    daoHelper.clearTempList(listId);
    return map;
}
项目:session-cloud    文件:CustomTokenStore.java   
public List<Map<String, String>> readCallBackUrlByClientId(Set<String> clientIds) {
       try {
        String parameterIds = "'" + Joiner.on("','").join(clientIds) + "'";
        return jdbcTemplate.query(CALLBACK_URL_CLIENT_ID_SELECT_STATEMENT + "(" + parameterIds + ")",new RowMapper<Map<String, String>>(){  

            @Override  
            public Map<String, String> mapRow(ResultSet rs, int rowNum) throws SQLException {  
                return ImmutableMap.of("clientId",rs.getString("client_id"),"callbackUrl",rs.getString("callback_url"),"clientSecret",rs.getString("client_secret"));
            }  
        });
    } catch (DataAccessException e) {
        e.printStackTrace();
    }

       return Collections.emptyList();
}
项目:NGB-master    文件:PersonDao.java   
static RowMapper<Person> getRowMapper() {
    return (rs, rowNum) -> {
        Person person = new Person();

        person.setId(rs.getLong(PERSON_ID.name()));
        person.setName(rs.getString(NAME.name()));
        person.setEmail(rs.getString(EMAIL.name()));

        long longVal = rs.getLong(ROLE_ID.name());
        if (!rs.wasNull()) {
            person.setRole(PersonRole.getRoleById(longVal));
        }

        return person;
    };
}
项目:Spring-5.0-Cookbook    文件:DepartmentDaoImpl.java   
@Override
public List<Department> getDepartments() {
    String sql = "SELECT * FROM department";
    List<Department> depts = jdbcInsert.getJdbcTemplate().query(sql, new RowMapper<Department>() {

        @Override
        public Department mapRow(ResultSet rs, int rowNum) throws SQLException {
            Department dept = new Department();
            dept.setId(rs.getInt("id"));
            dept.setDeptId(rs.getInt("deptId"));
            dept.setName(rs.getString("name"));
            return dept;
        }
    });
    return depts;
}
项目:lorne_mysql    文件:BaseJdbcTemplate.java   
public List<Map<String, Object>> listForMapList(String sql, int nowPage, int pageSize, Object... args) {
    sql = initSql(sql);
    String limitSql = null;
    try {
        limitSql = SelectLimitUtils.getLimitSql(sql, nowPage, pageSize);
    } catch (JSQLParserException e) {
        System.out.println(sql + ",格式不正确,请检查后再试.");
        return null;
    }

    Page<Map<String, Object>> page = new Page<Map<String, Object>>();
    List<Object> objs = new ArrayList<Object>();
    if (args != null && args.length > 0) {
        for (Object obj : args) {
            objs.add(obj);
        }
    }

    return getJdbcTemplate().query(limitSql, objs.toArray(), new RowMapper<Map<String, Object>>() {
        public Map<String, Object> mapRow(ResultSet rs, int i) throws SQLException {
            return toMap(rs);
        }
    });
}
项目:Spring-5.0-Cookbook    文件:LoginDaoImpl.java   
@Override
public AccountLogin getUser(String username) {
    String sql = "SELECT * FROM logindetails WHERE username=?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<AccountLogin>() {
        @Override
        public AccountLogin mapRow(ResultSet rs, int rowNum) throws SQLException {

            AccountLogin account = new AccountLogin();
            account.setId(rs.getInt("id"));
            account.setUsername(rs.getString("username"));
            account.setPassword(rs.getString("password"));
            account.setEncPassword(rs.getString("enc_password"));

            return account;
        }
    }, username);
}
项目:Spring-5.0-Cookbook    文件:EmployeeDaoImpl.java   
@Override
public Employee getEmployee(Integer id) {
    String sql = "SELECT * FROM employee WHERE id = ?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Employee>() {
        @Override
        public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {

            Employee emp = new Employee();

            emp.setId(rs.getInt("id"));
            emp.setEmpId(rs.getInt("empId"));
            emp.setFirstName(rs.getString("firstName"));
            emp.setLastName(rs.getString("lastName"));
            emp.setBirthday(rs.getDate("birthday"));
            emp.setAge(rs.getInt("age"));
            emp.setEmail(rs.getString("email"));
            emp.setDeptId(rs.getInt("deptId"));
            return emp;
        }
    }, id);
}
项目:Spring-5.0-Cookbook    文件:DepartmentDaoImpl.java   
@Override
public List<Department> getDepartments() {
    String sql = "SELECT * FROM department";
    List<Department> depts = jdbcInsert.getJdbcTemplate().query(sql, new RowMapper<Department>() {

        @Override
        public Department mapRow(ResultSet rs, int rowNum) throws SQLException {
            Department dept = new Department();
            dept.setId(rs.getInt("id"));
            dept.setDeptId(rs.getInt("deptId"));
            dept.setName(rs.getString("name"));
            return dept;
        }
    });
    return depts;
}
项目:Spring-5.0-Cookbook    文件:LoginDaoImpl.java   
@Override
public List<RolePermission> getUserGrantedAuthority(int userId) {
    String sql = "SELECT * FROM role_permission WHERE userId=?";
    List<RolePermission> roleperms = jdbcInsert.getJdbcTemplate().query(sql, new Object[]{userId}, new RowMapper<RolePermission>() {

        @Override
        public RolePermission mapRow(ResultSet rs, int rowNum) throws SQLException {
            RolePermission roleperm = new RolePermission();
            roleperm.setId(rs.getInt("id"));
            roleperm.setRoleId(rs.getInt("roleId"));
            roleperm.setPermissionId(rs.getInt("permissionId"));
            roleperm.setUserId(rs.getInt("userId"));

            return roleperm;
        }
    });
    return roleperms;
}
项目:bdf2    文件:LobStoreServiceImpl.java   
public byte[] getBytes(String id) throws SQLException {
    final String sql = "SELECT CONTENT_ FROM BDF2_BLOB_STORE WHERE ID_=?";
    List<byte[]> list = super.getJdbcTemplate().query(sql,
            new Object[] { id }, new RowMapper<byte[]>() {
                public byte[] mapRow(ResultSet resultset, int i)
                        throws SQLException {
                    byte[] content = LobStoreServiceImpl.this
                            .getLobHandler().getBlobAsBytes(resultset, 1);
                    return content;
                }

            });
    if(list.size()>0){
        return list.get(0);
    }else{
        return null;
    }
}
项目:Spring-5.0-Cookbook    文件:LoginDaoImpl.java   
@Override
public Role getUserRole(int id) {
    String sql = "SELECT * FROM role WHERE id=?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Role>() {
        @Override
        public Role mapRow(ResultSet rs, int rowNum) throws SQLException {

            Role role = new Role();
               role.setId(rs.getInt("id"));
            role.setName(rs.getString("name"));
            role.setDescription(rs.getString("description"));

            return role;
        }
    }, id);
}
项目:Spring-5.0-Cookbook    文件:LoginDaoImpl.java   
@Override
public Permission getPermission(int id) {
    String sql = "SELECT * FROM permission WHERE id=?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Permission>() {
        @Override
        public Permission mapRow(ResultSet rs, int rowNum) throws SQLException {

            Permission perm = new Permission();
            perm.setId(rs.getInt("id"));
            perm.setName(rs.getString("name"));
            perm.setDescription(rs.getString("description"));

            return perm;
        }
    }, id);
}
项目:Learning-Spring-5.0    文件:BookDAO_JdbcTemplate.java   
@Override
public Book getBook(long ISBN) {
    // TODO Auto-generated method stub
    String FIND_By_ID = "select * from book where ISBN=?";
    System.out.println("invoked" + ISBN);
    return jdbcTemplate.queryForObject(FIND_By_ID, new Object[] { ISBN }, new RowMapper<Book>() {

        @Override
        public Book mapRow(ResultSet set, int arg1) throws SQLException {
            // TODO Auto-generated method stub
            Book book = null;
            book = new Book();
            book.setAuthor(set.getString("author"));
            book.setBookName(set.getString("bookName"));
            book.setISBN(set.getLong("ISBN"));
            book.setPublication(set.getString("publication"));
            book.setDescription(set.getString("description"));
            System.out.println(book.getAuthor() + book.getISBN());
            return book;
        }
    });
}
项目:Spring-5.0-Cookbook    文件:DepartmentDaoImpl.java   
@Override
public List<Department> getDepartments() {
    String sql = "SELECT * FROM department";
    List<Department> depts = jdbcInsert.getJdbcTemplate().query(sql, new RowMapper<Department>() {

        @Override
        public Department mapRow(ResultSet rs, int rowNum) throws SQLException {
            Department dept = new Department();
            dept.setId(rs.getInt("id"));
            dept.setDeptId(rs.getInt("deptId"));
            dept.setName(rs.getString("name"));
            return dept;
        }
    });
    return depts;
}
项目:NGB-master    文件:ProjectDao.java   
static RowMapper<Project> getRowMapper() {
    return (rs, rowNum) -> {
        Project project = new Project();

        project.setId(rs.getLong(PROJECT_ID.name()));
        project.setName(rs.getString(PROJECT_NAME.name()));
        project.setCreatedBy(rs.getLong(CREATED_BY.name()));
        project.setCreatedDate(new Date(rs.getTimestamp(CREATED_DATE.name()).getTime()));
        project.setLastOpenedDate(new Date(rs.getTimestamp(LAST_OPENED_DATE.name()).getTime()));

        long longVal = rs.getLong(PARENT_ID.name());
        if (!rs.wasNull()) {
            project.setParentId(longVal);
        }

        return project;
    };
}
项目:Spring-5.0-Cookbook    文件:EmployeeDaoImpl.java   
@Override
public Employee getEmployee(Integer id) {
    String sql = "SELECT * FROM employee WHERE id = ?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Employee>() {
        @Override
        public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {

            Employee emp = new Employee();

            emp.setId(rs.getInt("id"));
            emp.setEmpId(rs.getInt("empId"));
            emp.setFirstName(rs.getString("firstName"));
            emp.setLastName(rs.getString("lastName"));
            emp.setBirthday(rs.getDate("birthday"));
            emp.setAge(rs.getInt("age"));
            emp.setEmail(rs.getString("email"));
            emp.setDeptId(rs.getInt("deptId"));
            return emp;
        }
    }, id);
}
项目:lams    文件:AbstractJdbcCall.java   
/**
 * Add a {@link org.springframework.jdbc.core.RowMapper} for the specified parameter or column.
 * @param parameterName name of parameter or column
 * @param rowMapper the RowMapper implementation to use
 */
public void addDeclaredRowMapper(String parameterName, RowMapper<?> rowMapper) {
    this.declaredRowMappers.put(parameterName, rowMapper);
    if (logger.isDebugEnabled()) {
        logger.debug("Added row mapper for [" + getProcedureName() + "]: " + parameterName);
    }
}
项目:spring-data-jdbc    文件:JdbcQueryLookupStrategy.java   
/**
 * Creates a new {@link AbstractQueryLookupStrategy}.
 *
 * @param em
 * @param extractor
 * @param evaluationContextProvider
 */
public AbstractQueryLookupStrategy(SqlGenerator generator, NamedParameterJdbcOperations template, RowMapper rowMapper,
                                   TableDescription tableDescription) {
    this.generator = generator;
    this.template = template;
    this.rowMapper = rowMapper;
    this.tableDescription = tableDescription;
}
项目:spring-data-jdbc    文件:JdbcAnnotatedRepositoryQueryCreator.java   
public JdbcAnnotatedRepositoryQueryCreator(JdbcQueryMethod method, SqlGenerator builder,
                                           NamedParameterJdbcOperations template, TableDescription tableDescription,
                                           @SuppressWarnings("rawtypes")
                                                   RowMapper rowMapper) {
    this.method = method;
    this.builder = builder;
    this.template = template;
    this.rowMapper = rowMapper;
    this.tableDescription = tableDescription;
    this.strategy = chooseStrategy(method);
    prepareQuery(method);
}
项目:lorne_mysql    文件:BaseJdbcTemplate.java   
public List<Map<String, Object>> queryForMapList(String sql) {
    return getJdbcTemplate().query(initSql(sql), new RowMapper<Map<String, Object>>() {
        public Map<String, Object> mapRow(ResultSet rs, int i) throws SQLException {
            return toMap(rs);
        }
    });
}
项目:simple-openid-provider    文件:JdbcClientRepositoryTests.java   
@Test
@SuppressWarnings("unchecked")
public void findAll_Na_ShouldReturnEmptyList() {
    given(this.jdbcOperations.query(anyString(), any(RowMapper.class))).willReturn(Collections.emptyList());

    assertThat(this.clientRepository.findAll()).isEmpty();
    verify(this.jdbcOperations, times(1)).query(and(startsWith("SELECT"), not(endsWith("WHERE id = ?"))),
            any(RowMapper.class));
    verifyZeroInteractions(this.jdbcOperations);
}
项目:NGB-master    文件:SegFileDao.java   
/**
 * Load sample metadata from the database for all files, corresponding the given reference ID.
 *
 * @param referenceId {@code long} reference ID for which files samples were saved.
 * @return {@code Map&lt;Long, List&lt;Sample&gt;&gt;} with file IDs for giver reference ID as keys, and with
 * lists of samples, corresponding this file IDs as values.
 */
@Transactional(propagation = Propagation.MANDATORY)
public Map<Long, List<SegSample>> loadSamplesForFilesByReference(long referenceId) {
    Map<Long, List<SegSample>> sampleFileMap = new HashMap<>();

    RowMapper<SegSample> sampleMapper = SegSampleParameters.getSegSampleMapper();

    getJdbcTemplate().query(loadSamplesForFilesByReferenceIdQuery, rs -> {
        Long fileId = rs.getLong(SegSampleParameters.SEG_ID.name());
        if (!sampleFileMap.containsKey(fileId)) {
            sampleFileMap.put(fileId, new ArrayList<>());
        }

        SegSample segSample = sampleMapper.mapRow(rs, 0);

        sampleFileMap.get(fileId).add(segSample);
    }, referenceId);

    return sampleFileMap;
}
项目:bdf2    文件:ValidatorManager.java   
public Collection<Validator> loadValidators(final String fieldId){
    String sql="select ID_,NAME_,DESC_ from BDF_R_VALIDATOR where FIELD_ID_=?";
    return this.getJdbcTemplate().query(sql,new Object[]{fieldId},new RowMapper<Validator>(){
        public Validator mapRow(ResultSet rs, int rowNum)
                throws SQLException {
            Validator v=new Validator();
            v.setId(rs.getString(1));
            v.setName(rs.getString(2));
            v.setDesc(rs.getString(3));
            v.setFieldId(fieldId);
            return v;
        }
    });
}
项目:batch-scheduler    文件:GroupTaskDaoImpl.java   
@Transactional
@Override
public List<GroupTaskEntity> getTaskDependency(String id) {
    RowMapper<GroupTaskEntity> rowMapper = new BeanPropertyRowMapper<>(GroupTaskEntity.class);
    List<GroupTaskEntity> list = jdbcTemplate.query(batchSqlText.getSql("sys_rdbms_134"), rowMapper, id);
    return list;
}
项目:spring-data-jdbc-template    文件:JdbcTemplateRepositoryQuery.java   
@SuppressWarnings("unchecked")
private <S> RowMapper<S> getEntityRowMapper(JdbcTemplateQueryMethod queryMethod, Class<S> resultType) {
    Class<? extends EntityMapper<?>> mapperClass = null;

    if (queryMethod.mapperClass != null) {
        mapperClass = queryMethod.mapperClass;
    } else if (resultType.getAnnotation(Mapper.class) != null) {
        Mapper mapping = resultType.getAnnotation(Mapper.class);
        mapperClass = mapping.value();
    }
    return EntityRowMapper.create(resultType, mapperClass);
}
项目:Learning-Spring-5.0    文件:BookDAO_JdbcTemplate.java   
@Override
    public Book serachBook(long ISBN) {
        // TODO Auto-generated method stub
        String SEARCH_BOOK = "select * from book where ISBN=?";
        Book book_serached = null;
        try {
            book_serached = jdbcTemplate.queryForObject(SEARCH_BOOK, new Object[] { ISBN }, new RowMapper<Book>() {

                @Override
                public Book mapRow(ResultSet set, int rowNum) throws SQLException {
                    // TODO Auto-generated method stub

                    Book book = new Book();
                    book.setBookName(set.getString("bookName"));
                    book.setAuthor(set.getString("author"));
                    book.setDescription(set.getString("description"));
                    book.setISBN(set.getLong("ISBN"));
                    book.setPrice(set.getInt("price"));
                    book.setPublication(set.getString("publication"));
                    return book;
                }
            });
            return book_serached;
        } catch (EmptyResultDataAccessException ex) {
//          ex.printStackTrace();
            return new Book();
        }
    }
项目:bdf2    文件:ComponentManager.java   
public Collection<ComponentProperty> loadComponentProperties(String componentId){
    String sql="select ID_,NAME_,VALUE_,COMPONENT_ID_ from BDF_R_COMPONENT_PROPERTY where COMPONENT_ID_=?";
    return this.getJdbcTemplate().query(sql,new Object[]{componentId},new RowMapper<ComponentProperty>(){
        public ComponentProperty mapRow(ResultSet rs, int rowNum)
                throws SQLException {
            ComponentProperty cp=new ComponentProperty();
            cp.setId(rs.getString(1));
            cp.setName(rs.getString(2));
            cp.setValue(rs.getString(3));
            cp.setComponentId(rs.getString(4));
            return cp;
        }
    });
}
项目:Spring-5.0-Cookbook    文件:DepartmentDaoImpl.java   
@Override
public Department getDepartmentData(Integer id) {
    String sql = "SELECT * FROM department WHERE id = ?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Department>() {
        @Override
        public Department mapRow(ResultSet rs, int rowNum) throws SQLException {

            Department dept = new Department();
            dept.setId(rs.getInt("id"));
            dept.setDeptId(rs.getInt("deptId"));
            dept.setName(rs.getString("name"));
            return dept;
        }
    }, id);
}
项目:NGB-master    文件:BucketDao.java   
static RowMapper<Bucket> getPasswordRowMapper() {
    return (rs, rowNum) -> {
        Bucket bucket = new Bucket();

        bucket.setId(rs.getLong(BUCKET_ID.name()));
        bucket.setBucketName(rs.getString(BUCKET_NAME.name()));
        bucket.setAccessKeyId(rs.getString(ACCESS_KEY_ID.name()));
        bucket.setSecretAccessKey(rs.getString(SECRET_ACCESS_KEY.name()));

        return bucket;
    };
}
项目:bdf2    文件:DefaultUrlService.java   
public List<Url> loadUrlsByRoleId(String roleId) {
    String sql="SELECT U.ID_,U.URL_,U.COMPANY_ID_,U.NAME_ FROM BDF2_ROLE_RESOURCE R INNER JOIN BDF2_URL U ON R.URL_ID_=U.ID_ WHERE ROLE_ID_=?";
    return this.getJdbcTemplate().query(sql,new Object[]{roleId},new RowMapper<Url>(){
        public Url mapRow(ResultSet rs, int rowNum) throws SQLException {
            Url url=new Url();
            url.setId(rs.getString("ID_"));
            url.setUrl(rs.getString("URL_"));
            url.setName(rs.getString("NAME_"));
            url.setCompanyId(rs.getString("COMPANY_ID_"));
            return url;
        }
    });
}
项目:Spring-5.0-Cookbook    文件:DepartmentDaoImpl.java   
@Override
public Department getDepartmentData(Integer id) {
    String sql = "SELECT * FROM department WHERE id = ?";
    return jdbcInsert.getJdbcTemplate().queryForObject(sql, new RowMapper<Department>() {
        @Override
        public Department mapRow(ResultSet rs, int rowNum) throws SQLException {

            Department dept = new Department();
            dept.setId(rs.getInt("id"));
            dept.setDeptId(rs.getInt("deptId"));
            dept.setName(rs.getString("name"));
            return dept;
        }
    }, id);
}
项目:FastSQL    文件:PageTemplate.java   
public <T> ResultPage<T> queryPage(String sql, int page, int perPage, SqlParameterSource paramSource, RowMapper<T> rowMapper, DataSourceType dataSourceType) {
    String rowsSQL = PageUtils.getRowsSQL(sql, page, perPage, dataSourceType);
    List<T> list = namedParameterJdbcTemplate.query(
            rowsSQL,
            paramSource,
            rowMapper);

    //查询数量
    String numberSQL = PageUtils.getNumberSQL(sql);
    Integer number = namedParameterJdbcTemplate.queryForObject(
            numberSQL,
            paramSource,
            Integer.class);
    return new ResultPage<T>(list, number);
}
项目:spwrap    文件:SpringResultSetAutoMapper.java   
public T map(Result<?> result) {

        ResultSet rs = (ResultSet) result.wrappedObject();
        RowMapper<T> rowMapper;

        try {
            rowMapper = (rs.getMetaData().getColumnCount() == 1) ? singleColumnRowMapper : beanPropertyRowMapper;
            return rowMapper.mapRow(rs, getRowIndex(result));
        } catch (SQLException e) {
            throw new CallException(e.getMessage(), e);
        }
    }