Home > database >  How to map bean property name to table column names with BeanPropertyRowMapper if column names are d
How to map bean property name to table column names with BeanPropertyRowMapper if column names are d

Time:11-03

Hi i am trying to map my data class to jdbcTemplate result set . Its mapping all the columns which are matching with the result set but if its different its not mapping . Do we have any annotation to map such columns ? Funding class is not Entity class.

 @Data
 public class Funding {

 private Long loanId; // DataBase Column name is LOAN_ID - This is mapping correctly 
 private String sellerLoanId;// Database Column name is L_SELLER_LOAN_ID - This is not 
                         //  mapping. 
 }

 mapper = BeanPropertyRowMapper.newInstance(Funding.class);
 List<Funding>  fundingValues =  this.jdbcTemplate.query(sql,mapper);

 I tried with annotations like 
 @Column(name = "L_SELLER_LOAN_ID")

CodePudding user response:

You have to implement your own Mapper.

See the example on springjdbc_rowmapper

  • Related