关于数据库查询new BeanPropertyRowMapper

Posted jiangzishun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于数据库查询new BeanPropertyRowMapper相关的知识,希望对你有一定的参考价值。

//bean类必须有无参构造,不然new BeanPropertyRowMapper<bean>(bean.class)不会把数据转为bean对象

@Test
public void test3() throws PropertyVetoException { // List<bean> query = jdbcTemplate.query("select * from jiang", new BeanPropertyRowMapper<>(bean.class)); List<bean> query = jdbcTemplate.query("select * from jiang",new BeanPropertyRowMapper<bean>(bean.class)); System.out.println(query); }
package com.jiang;

public class bean {
    private String username;
    private String password;

    public bean() {
    }

    public bean(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "bean{" +
                "username=‘" + username + ‘‘‘ +
                ", password=‘" + password + ‘‘‘ +
                ‘}‘;
    }
}

 

以上是关于关于数据库查询new BeanPropertyRowMapper的主要内容,如果未能解决你的问题,请参考以下文章

thymeleaf关于Map的取值

关于oracle触发器的一个问题,求解答

关于mysql中触发器old和new

后台使用new Date();查询数据 springmvc+mybatis

关于c++中new和delete

关于new操作符如何实现C中的realloc函数