开发者

java web application - model design for displaying list with a sql join

I am authoring a javabean and would like to know if it should include properties to set values obtained from a sql join? Say I have database tables for Products and Orders. These are also my java bean names.

Now I want to display a list of all products but in addition to all the product properties, I want to have columns to display last purchase date and last purchased by

My db query to get the product list would need to do joins to gather the additional info. It does not seem correct to have setters and getters for `last purchase date and last purchased by' in开发者_StackOverflow中文版 Product.java model. I may want to have a 3rd column so constantly adding new columns to my bean doesn't make sense.

How do you go about this? I seem to encounter this when needing to display lists of models in my view.


Have a Map in Product. Upon firing the sql, store hte results of the join as key value pair in the Map. K=lastpurchasedby(columnName) and V= the value So no need to add individual attributes. They all come in key-value pairs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜