开发者

jsp jdbc data access layer design

Hi: I have a question about how to design and map object class in java with database(sql).

For example, if I have Customer and Order Class which match with Customer and Order Table in database. If I need the Customer and Order information separately, I simply use SQL query to fetch the information from database table and put them into List and List, and display in front end application. What if I need to display to display bo开发者_运维技巧th Customer and Order information at the same time? How do put both Customer and Order object in one single arraylist?

If anyone can help me answering this question in either jsp or asp.net, i will be appreciated.

Thanks


First - don't do this in a jsp. Do it in a regular class invoked by a servlet/controller. Then take a look at some ORM - hibernate, eclipselink. But it might be too complicated for a simple project. Also look at commons-dbutils.


One possible approach is to construct a transfer object which includes the necessary information from both objects, and put the TO into a list.

Check http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html and http://en.wikipedia.org/wiki/Data_transfer_object for more information on this pattern.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜