The question about BeanListHandler

product (merchandise) is a member variable of a javabean, class that contains another Javabean, that is, category (commodity category), but my database product table stores cid (identification of commodity category) rather than commodity category. In the background dao layer asked for data from the database when using the beanlisthandler object, it can still be encapsulated into a complete product object, may I ask why?

related codes

/ /
product class

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 class

private String cid;
private String cname;

dao layer code

public List<Product> 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>(Product.class), 1,0,9);
}

clipboard.png
this is my product table

Why can it be encapsulated into a complete product object through cid when accessing the database?

Apr.03,2021

for the entity manager, it finds that Product.category is a Category type also registered as an entity, and the primary key of this type is cid , so it knows that cid corresponds to the primary key of the category table in the query results.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b29d-2c264.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b29d-2c264.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?