org.apache.commons.dbutils.handlers.BeanMapHandler Java Examples

The following examples show how to use org.apache.commons.dbutils.handlers.BeanMapHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueryTest.java    From search-commons with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore
public void beanQueryTest() {
    BeanQueryParam<Country> beanQueryParam = Queries.beanParam("tqdb_base", "db_country", Country.class);
    beanQueryParam.setQueryCondition(Queries.DEFAULT_DELETED_CONTAINER);
    BeanMapHandler<Integer, Country> beanMapHandler = Queries.beanMapHandler(Country.class, "id");
    Map<Integer, Country> dataMap = queryRunner.query(beanQueryParam, beanMapHandler);
    Assert.assertFalse(dataMap.isEmpty());
    System.out.println(dataMap);
}
 
Example #2
Source File: DefaultDataAccessor.java    From smart-framework with Apache License 2.0 5 votes vote down vote up
@Override
public <K, V> Map<K, V> queryEntityMap(Class<V> entityClass, String sql, Object... params) {
    Map<K, V> entityMap;
    try {
        entityMap = queryRunner.query(sql, new BeanMapHandler<K, V>(entityClass), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return entityMap;
}
 
Example #3
Source File: DefaultDataAccessor.java    From smart-framework with Apache License 2.0 5 votes vote down vote up
@Override
public <K, V> Map<K, V> queryEntityMap(Class<V> entityClass, String sql, Object... params) {
    Map<K, V> entityMap;
    try {
        entityMap = queryRunner.query(sql, new BeanMapHandler<K, V>(entityClass), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return entityMap;
}
 
Example #4
Source File: DefaultQueryRunner.java    From search-commons with Apache License 2.0 4 votes vote down vote up
@Override
public <K, V> Map<K, V> query(BeanQueryParam<V> param, BeanMapHandler<K, V> handler) {
    return query(param.sqlStatement(), handler);
}
 
Example #5
Source File: MysqlQueryRunner.java    From search-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Map<K, Bean> query
 *
 * @param handler bean处理器, 通过{@link Queries#beanMapHandler(Class)}, {@link Queries#beanMapHandler(Class, int)},
 *                {@link Queries#beanMapHandler(Class, String)}获取
 * @param <K>     Map的key
 * @param <V>     bean class type
 * @see Queries#beanMapHandler(Class)
 * @see Queries#beanMapHandler(Class, int)
 * @see Queries#beanMapHandler(Class, String)
 */
<K, V> Map<K, V> query(BeanQueryParam<V> param, BeanMapHandler<K, V> handler);