product(商品)是一个javabean,类里面的成员变量包含了另一个Javabean,即category(商品种类),可是我的数据库product表中存放的是cid(商品种类的标识)而不是商品种类,在后台dao层向数据库要数据的时候使用了beanlisthandler对象,仍然能够封装成完整的product对象,请问这是为什么?
相关代码
//
product类
private String pid;
private String pname;
private double market_price;
private double shop_price;
private String pimage;
private Date pdate;
private int is_hot;
private String pdesc;
private int pflag;
private Category category;
category类
private String cid;
private String cname;
dao层代码
public List findHotProductList() throws SQLException {
QueryRunner runner=new QueryRunner(DataSourceUtils.getDataSource());
String sql="select * from product where is_hot =? limit ?,?";
return runner.query(sql, new BeanListHandler(Product.class), 1,0,9);
}
这是我的product表
为什么在访问数据库时候可以通过cid就能封装成完整的product对象?