当前位置: 首页>>代码示例>>Java>>正文


Java BeanPropertyRowMapper类代码示例

本文整理汇总了Java中org.springframework.jdbc.core.BeanPropertyRowMapper的典型用法代码示例。如果您正苦于以下问题:Java BeanPropertyRowMapper类的具体用法?Java BeanPropertyRowMapper怎么用?Java BeanPropertyRowMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanPropertyRowMapper类属于org.springframework.jdbc.core包,在下文中一共展示了BeanPropertyRowMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findAll

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<SysConfigEntity> findAll(String domainId) {
    RowMapper<SysConfigEntity> rowMapper = new BeanPropertyRowMapper<SysConfigEntity>(SysConfigEntity.class);
    List<SysConfigEntity> list = jdbcTemplate.query(batchSqlText.getSql("sys_rdbms_181"), rowMapper);
    List<SysConfigEntity> list2 = jdbcTemplate.query(batchSqlText.getSql("sys_rdbms_187"), rowMapper, domainId);
    Map<String, SysConfigEntity> map = new HashMap<>();

    for (int i = 0; i < list2.size(); i++) {
        map.put(list2.get(i).getConfigId(), list2.get(i));
    }

    for (int i = 0; i < list.size(); i++) {
        String cid = list.get(i).getConfigId();
        if (map.containsKey(cid)) {
            list.get(i).setConfigValue(map.get(cid).getConfigValue());
        }
    }
    return list;
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:20,代码来源:SysConfigDaoImpl.java

示例2: getChanges

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Return all status changes of issues of given project and last known issue values : due date, resolution,
 * reporter,... in type {@link IssueDetails}.
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param jira
 *            the JIRA project identifier.
 * @param pkey
 *            the project 'pkey'.
 * @param authoring
 *            When <code>true</code> authors are fetched for changes.
 * @param timing
 *            When <code>true</code> time spent data is fetched.
 * @return status changes of all issues of given project.
 */
public List<JiraChangeItem> getChanges(final DataSource dataSource, final int jira, final String pkey, final boolean authoring,
		final boolean timing) {
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
	final RowMapper<JiraChangeItem> rowMapper = new BeanPropertyRowMapper<>(JiraChangeItem.class);

	// First, get all created issues (first change)
	final List<JiraChangeItem> changes = getChanges(dataSource, jira, pkey, JiraChangeItem.class, timing, false);

	// Then add all status changes
	changes.addAll(jdbcTemplate.query(
			"SELECT i.ID AS id, cgi.OLDVALUE AS fromStatus, cgi.NEWVALUE AS toStatus, cg.CREATED AS created"
					+ (authoring ? ", cg.AUTHOR as author" : "")
					+ " FROM changeitem cgi INNER JOIN changegroup AS cg ON (cgi.groupid = cg.ID) INNER JOIN jiraissue AS i ON (cg.issueid = i.ID)"
					+ " WHERE cgi.FIELD = ? AND cgi.OLDVALUE IS NOT NULL AND cgi.NEWVALUE IS NOT NULL AND cg.CREATED IS NOT NULL AND i.PROJECT = ?",
			rowMapper, "status", jira));

	/*
	 * Then sort the result by "created" date. The previous SQL query did not used since order had to be applied to
	 * the whole collection. In addition, the result set of the previous query "should already been ordered since
	 * the natural order in this table is chronological.
	 */
	changes.sort(Comparator.comparing(IssueDetails::getCreated));
	return changes;
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:41,代码来源:JiraDao.java

示例3: selectOneWhere

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
/**
 * 通过where条件查找一条记录
 * 查找姓名为1年龄大于23的记录  selectOneWhere("name=? and age>?", "wang",23)
 *
 * @param sqlCondition name=:1 and age=:2
 * @param values       "wang",23
 */
public E selectOneWhere(String sqlCondition, Object... values) {
    //sql
    String sql = "SELECT * FROM " + tableName + " WHERE " + sqlCondition;

    List<E> dataList = getSqlFactory().createSQL().useSql(sql)
            .varParameter(values)
            .queryList(new BeanPropertyRowMapper<>(entityClass));

    if (dataList.isEmpty()) {
        return null;
    } else if (dataList.size() == 1) {
        return dataList.get(0);
    } else {
        log.error(tableName + "#findOneWhere()返回多条数据");
        throw new RuntimeException(tableName + "#findOneWhere()返回多条数据");
    }
}
 
开发者ID:fast-sql,项目名称:FastSQL,代码行数:25,代码来源:BaseDAO.java

示例4: findRandomRecommendArticleList

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<TArticle> findRandomRecommendArticleList(final int count) {
    List<Object> params = new ArrayList<Object>();
    StringBuffer sql = new StringBuffer();
    // 为了提升性能,没有用hibernate,写了nactiveSQL
    sql.append(" SELECT * ");
    sql.append(" FROM  ( ");
    sql.append("    SELECT DISTINCT 1 + floor(RAND() * (select max(articleno) from t_article) ) AS articleno ");
    sql.append("    FROM   (select     @num:[email protected]+1  from   t_chapter,   (select @num:=0) aa  LIMIT 50 ) g ");
    sql.append("    ) r ");
    sql.append(" JOIN   t_article USING (articleno) ");
    sql.append(" where  deleteflag = false ");
    sql.append(" AND lastupdate is not null  ");
    sql.append(" AND lastchapterno is not null ");
    sql.append("LIMIT  ?");
    params.add(count);

    return this.yiduJdbcTemplate.query(sql.toString(), params.toArray(), new BeanPropertyRowMapper<TArticle>(
            TArticle.class));
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:21,代码来源:ArticleServiceImpl.java

示例5: findWithArticleInfo

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<BookcaseDTO> findWithArticleInfo(BookcaseSearchBean searchBean) {
    // 初期SQL做成
    StringBuffer sql = new StringBuffer();
    sql.append("Select tb.*,ta.lastchapterno,ta.lastchapter,ta.chapters,ta.size,ta.fullflag,ta.lastupdate "
            + " ,ta.imgflag ,ta.pinyin  "
            + "      FROM t_bookcase tb                                                                     "
            + "      LEFT JOIN t_article ta ON tb.articleno = ta.articleno                                  "
            + "WHERE tb.userno= ");
    sql.append(searchBean.getUserno());
    // 添加排序信息
    if (searchBean.getPagination() != null) {
        sql.append(searchBean.getPagination().getSortInfo());
    } else {
        sql.append("ORDER BY ta.lastupdate DESC");
    }
    return yiduJdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<BookcaseDTO>(BookcaseDTO.class));
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:19,代码来源:BookcaseServiceImpl.java

示例6: findAllData

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<SubscribeDTO> findAllData(SubscribeSearchBean searchBean) {
    StringBuffer sql = new StringBuffer();
    sql.append("SELECT ts.subscribeno, ta.* , tu.userno,tu.loginid,tu.email FROM t_subscribe ts ");
    sql.append(" join t_article ta on ts.articleno = ta.articleno ");
    sql.append(" join t_user tu on tu.userno = ts.userno ");
    sql.append(" where ta.deleteflag = false and  tu.deleteflag = false ");
    if (Utils.isDefined(searchBean.getUserno())) {
        sql.append(" AND ts.userno =  " + searchBean.getUserno());
    }

    if (Utils.isDefined(searchBean.getDateRange())) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.sss");
        sql.append(" AND ta.lastupdate >= '" + sdf.format(searchBean.getDateRange().getMinimum()) + "'");
        sql.append(" AND ta.lastupdate < '" + sdf.format(searchBean.getDateRange().getMaximum()) + "'");
    }
    sql.append(" order by ts.articleno ");

    List<Object> params = new ArrayList<Object>();
    List<SubscribeDTO> subscribeList = this.yiduJdbcTemplate.query(sql.toString(), params.toArray(),
            new BeanPropertyRowMapper<SubscribeDTO>(SubscribeDTO.class));
    return subscribeList;
}
 
开发者ID:luckyyeah,项目名称:YiDu-Novel,代码行数:24,代码来源:SubscribeServiceImpl.java

示例7: testSpringXaTx

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Test
public void testSpringXaTx() throws Exception {
    DataSource ds = wrap(createHsqlDataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(ptm);

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    tx.execute(ts -> jdbc.update(INSERT_INTO_USER, 1, "user1"));
    User user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
    assertEquals(new User(1, "user1"), user);
    tx.execute(ts -> jdbc.update(DELETE_FROM_USER_BY_ID, 1));

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:27,代码来源:HsqlTest.java

示例8: testSpringLocalTx

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Test
public void testSpringLocalTx() throws Exception {
    DataSource ds = wrap(createHsqlDataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(new DataSourceTransactionManager(ds));

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    tx.execute(ts -> jdbc.update(INSERT_INTO_USER, 1, "user1"));
    User user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
    assertEquals(new User(1, "user1"), user);
    tx.execute(ts -> jdbc.update(DELETE_FROM_USER_BY_ID, 1));

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:27,代码来源:HsqlTest.java

示例9: testSpringXaTx

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Test
public void testSpringXaTx() throws Exception {
    DataSource ds = wrap(createH2DataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(ptm);

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    tx.execute(ts -> jdbc.update(INSERT_INTO_USER, 1, "user1"));
    User user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
    assertEquals(new User(1, "user1"), user);
    tx.execute(ts -> jdbc.update(DELETE_FROM_USER_BY_ID, 1));

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:27,代码来源:H2Test.java

示例10: testSpringLocalTx

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Test
public void testSpringLocalTx() throws Exception {
    DataSource ds = wrap(createH2DataSource());
    JdbcTemplate jdbc = new JdbcTemplate(ds);
    TransactionTemplate tx = new TransactionTemplate(new DataSourceTransactionManager(ds));

    jdbc.execute(DROP_USER);
    jdbc.execute(CREATE_TABLE_USER);

    tx.execute(ts -> jdbc.update(INSERT_INTO_USER, 1, "user1"));
    User user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
    assertEquals(new User(1, "user1"), user);
    tx.execute(ts -> jdbc.update(DELETE_FROM_USER_BY_ID, 1));

    tx.execute(ts -> {
        int nb = jdbc.update(INSERT_INTO_USER, 1, "user1");
        ts.setRollbackOnly();
        return nb;
    });
    try {
        user = tx.execute(ts -> jdbc.queryForObject(SELECT_FROM_USER_BY_ID, new BeanPropertyRowMapper<>(User.class), 1));
        fail("Expected a EmptyResultDataAccessException");
    } catch (EmptyResultDataAccessException e) {
        // expected
    }
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:27,代码来源:H2Test.java

示例11: findRandomRecommendArticleList

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<TArticle> findRandomRecommendArticleList(final int count) {
    List<Object> params = new ArrayList<Object>();
    StringBuffer sql = new StringBuffer();
    // 为了提升性能,没有用hibernate,写了nactiveSQL
    sql.append(" SELECT * ");
    sql.append(" FROM  ( ");
    sql.append("    SELECT DISTINCT 1 + floor(random() * (select max(articleno) from t_article) )::integer AS articleno ");
    sql.append("    FROM   generate_series(1, 50) g ");
    sql.append("    ) r ");
    sql.append(" JOIN   t_article USING (articleno) ");
    sql.append(" where  deleteflag = false ");
    sql.append(" AND lastupdate is not null  ");
    sql.append(" AND lastchapterno is not null ");
    sql.append("LIMIT  ?");
    params.add(count);

    return this.yiduJdbcTemplate.query(sql.toString(), params.toArray(), new BeanPropertyRowMapper<TArticle>(
            TArticle.class));
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:21,代码来源:ArticleServiceImpl.java

示例12: findRelativeArticleList

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<TArticle> findRelativeArticleList(List<String> keys, String sortCol, boolean isAsc, int limitNum) {

    List<Object> params = new ArrayList<Object>();
    params.addAll(keys);
    params.add(sortCol);

    String cond = "";
    boolean isFirst = true;
    for (int i = 0; i < keys.size(); i++) {
        if (isFirst) {
            cond += " ?  % articlename ";
            isFirst = false;
        } else {
            cond += (" OR ?  % articlename ");
        }
    }
    String sql = "SELECT * FROM t_article where " + cond + "  order by ?  " + (isAsc ? "ASC" : "DESC") + " limit "
            + limitNum;
    return this.yiduJdbcTemplate.query(sql, params.toArray(), new BeanPropertyRowMapper<TArticle>(TArticle.class));
}
 
开发者ID:Chihpin,项目名称:Yidu,代码行数:22,代码来源:ArticleServiceImpl.java

示例13: locateRoutesFromDB

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
private Map<String, ZuulRoute> locateRoutesFromDB(){
    Map<String, ZuulRoute> routes = new LinkedHashMap<>();
    List<ZuulRouteVO> results = jdbcTemplate.query("select * from gateway_api_define where enabled = true ",new BeanPropertyRowMapper<>(ZuulRouteVO.class));
    for (ZuulRouteVO result : results) {
        if(org.apache.commons.lang3.StringUtils.isBlank(result.getPath()) /*|| org.apache.commons.lang3.StringUtils.isBlank(result.getUrl())*/ ){
            continue;
        }
        ZuulRoute zuulRoute = new ZuulRoute();
        try {
            org.springframework.beans.BeanUtils.copyProperties(result,zuulRoute);
        } catch (Exception e) {
            logger.error("=============load zuul route info from db with error==============",e);
        }
       // zuulRoute.setUrl(null);
       // zuulRoute.setRetryable(null);
        routes.put(zuulRoute.getPath(),zuulRoute);
    }
    return routes;
}
 
开发者ID:xiaomin0322,项目名称:zuul-gateway,代码行数:20,代码来源:CustomRouteLocator.java

示例14: findAll

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
@Override
public List<BatchGroupStatusEntity> findAll(String batchId, String asOfDate) {
    RowMapper<BatchGroupStatusEntity> rowMapper = new BeanPropertyRowMapper<>(BatchGroupStatusEntity.class);
    List<BatchGroupStatusEntity> list = jdbcTemplate.query(batchSqlText.getSql("sys_rdbms_201"), rowMapper, batchId, asOfDate);
    for (BatchGroupStatusEntity bh : list) {

        Integer totalCnt = getTotalJobs(batchId, bh.getSuiteKey(), asOfDate);

        Integer completeCnt = getCompleteJobs(batchId, bh.getSuiteKey(), asOfDate);

        bh.setTotalJobsCnt(totalCnt);

        bh.setCompleteJobsCnt(completeCnt);
    }
    return list;
}
 
开发者ID:hzwy23,项目名称:batch-scheduler,代码行数:17,代码来源:BatchGroupRunningDaoImpl.java

示例15: getCustomFieldsById

import org.springframework.jdbc.core.BeanPropertyRowMapper; //导入依赖的package包/类
/**
 * Return ordered custom fields by the given identifiers
 * 
 * @param dataSource
 *            The data source of JIRA database.
 * @param customFields
 *            the expected custom fields identifiers.
 * @param project
 *            Jira project identifier. Required to filter custom field agains contexts.
 * @return ordered custom fields by their identifier.
 */
public Map<Integer, CustomFieldEditor> getCustomFieldsById(final DataSource dataSource, final Set<Integer> customFields, final int project) {
	if (customFields.isEmpty()) {
		// No custom field, we save an useless query
		return new HashMap<>();
	}

	// Get map as list
	final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
	final RowMapper<CustomFieldEditor> rowMapper = new BeanPropertyRowMapper<>(CustomFieldEditor.class);
	final List<CustomFieldEditor> resultList = jdbcTemplate
			.query("SELECT ID AS id, TRIM(cfname) AS name, DESCRIPTION AS description, CUSTOMFIELDTYPEKEY AS fieldType FROM customfield WHERE ID IN ("
					+ newIn(customFields) + ") ORDER BY id", rowMapper, customFields.toArray());

	// Make a Map of valid values for single/multi select values field
	final Map<Integer, CustomFieldEditor> result = new LinkedHashMap<>();
	addListToMapIdentifier(dataSource, resultList, result, project);
	return result;
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:30,代码来源:JiraDao.java


注:本文中的org.springframework.jdbc.core.BeanPropertyRowMapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。