Examples of RowMapper


Examples of org.springframework.jdbc.core.RowMapper

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

Examples of org.springframework.jdbc.core.RowMapper

    @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

Examples of org.springframework.jdbc.core.RowMapper

                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

Examples of org.springframework.jdbc.core.RowMapper

                        "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

Examples of org.springframework.jdbc.core.RowMapper

            {
                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

Examples of org.springframework.jdbc.core.RowMapper

        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

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

Examples of org.springframework.jdbc.core.RowMapper

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