select * from product_account;
SELECT pa.pa_num,p.proName,p.proLimit,p.annualized,pa.interest,c.c_name,pa.pa_date,pa.money FROM product_account pa,product p,customer c WHERE pa.c_id=c.id AND pa.p_id=p.id AND c.id=?
QueryRunner runner = new QueryRunner(连接池)
List<Map<String,Object>> list = runner.query(sql, new MapListHandler(), id ) ;
List<ProductAcount> list2 = new ArrayList<ProductAcount>();
for(Map map : list) {
ProductAccount productAccount = new ProductAccount();
BeanUtils.populate(productAccount, map );
Customer customer = new Customer();
BeanUtils.populate(customer, map );
Product product = new Product();
BeanUtils.populate(product, map );
productAccount.setCustomer(customer);
productAccount.setProduct(product);
list2.add(productAccount);
}
return list2;
new BeanListHandler<ProductAccount>(ProductAccount.class)
class ProductAccount{
private String proName;
private String proLimit;
private String annualized;
...
}
多表联查时数据封装(无框架时)
最新推荐文章于 2024-05-28 22:41:39 发布