Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.RowMapper


public abstract class BaseBean {

  @SuppressWarnings("unchecked")
  public static RowMapper mapRow(final Class clazz) throws Exception{
    return new RowMapper(){
      public Object mapRow(ResultSet resultset, int rowNum)
          throws SQLException {
        Field[] fields = clazz.getDeclaredFields();
        Object o = null;
        try {
View Full Code Here


    public RowMapper getRowMapper(StatementMetaData modifier) {
        RowHandler rowHandler = modifier.getAnnotation(RowHandler.class);
        if (rowHandler != null) {
            if (rowHandler.rowMapper() != RowHandler.ByDefault.class) {
                try {
                    RowMapper rowMapper = rowHandler.rowMapper().newInstance();
                    if (logger.isInfoEnabled()) {
                        logger.info("using rowMapper " + rowMapper + " for " + modifier);
                    }

                    return rowMapper;
                } catch (Exception ex) {
                    throw new BeanInstantiationException(rowHandler.rowMapper(), ex.getMessage(),
                            ex);
                }
            }
        }
        //

        Class<?> returnClassType = modifier.getMethod().getReturnType();
        Class<?> rowType = getRowType(modifier);

        // BUGFIX: SingleColumnRowMapper 处理  Primitive Type 抛异常
        if (rowType.isPrimitive()) {
            rowType = ClassUtils.primitiveToWrapper(rowType);
        }

        // 根据类型创建  RowMapper
        RowMapper rowMapper;

        // 返回单列的查询的(或者返回只有2列的Map类型查询的)
        if (TypeUtils.isColumnType(rowType)) {
            if (returnClassType == Map.class) {
                rowMapper = new MapEntryColumnRowMapper(modifier, rowType);
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.