Mapping Business Objects to SQL Tables

Hello all,

I'm in first OO complex project and I've a few question regarding how to map SQL tables into Business Objects (and viceversa).

The project is a complex web site so I access Business Object from JSP.

The difference I noticed with JSP vs other apps is that all thing is stateless, ie., when I display a page a retrieve the list of news from a table, write the page, stop.

So I just need a data connection and don't need a "News" object.

So, at the end, the "News" object is a libray to store all news related methods.

Is my impression correct? or am I wrong in something?

Where can I find something that I can read about this?

Thank you

Simone

[716 byte] By [simonecha] at [2007-9-28 3:14:33]
# 1

I think you are just displaying the content in the JSP page. Business objects are meant for doing business processes. If your application is developed using a multi layered architecture then scope of these business objects would be only in the business layers. There you may need to have objects like News for manipulate data easily. After doing the business process you have to generate views for displaying the content in the JSP page. We would call it as dataBean or viewBean or JSPBean etc. This class holds data for the jsp page and some functions to display the content easily.

Hope it make sense to you

Thanks

PraveenKutty

kuttypraa at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 2
You are right, the http protocol is stateless, but JSPs aren't.you can store in the session or application context. And of course you can use Singletons or similar patterns to have one object for the whole application, for exampe a news cache.regardsSpieler
spielera at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
ThanxI come from ASP experience, and in ASP using Session and Application objects to store application was not a good idea...So JSP implements Session and Application in a better way than ASP did?That would be a great improvement.TySimo
simonecha at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 4
I don't know of any problems with the session and application objects,AFIK everybody is using them. Out of curiosity: What is the problem with these objects in the ASP world?
spielera at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 5

For curiosity:

Session object use is discuraged because using many objects inside Session may lead to a memory shortage if there are many user connected to website, and also because the MS marshaller must verify the type of each object stored... and sometimes it fails (when it's under havy load) so a recordset (the equivalent of Java ResultSet) is not identified as it is, so the ASP page will give runtime execution error becuase it cannot use for example the .MoveNext method of a non recordset object.... and so on...

This guideline is reccomended by MS... no comment

bye

Simo

simonecha at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 6
poor ASP programmers ;(
spielera at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...
# 7

How about create some "View" classes to handle?

You can use the "Business Object" tables like (news, users..etc) to trigger "View" tables like (NewsListView, UserListView..etc) in SQL Server. And then, define NewsItemList Objects as beans to display relevant information in JSP.

It is good practice to distinguish "BO" tables from "View" tables just same as "Business" Object is used to handle business process, while "View" Object as a bean is reserved to display in JSP.

In a sense, it is NOT necessary that "View object" inherits all attributes of "Business bject". It is used only for display in JSP. For example, you may want to list NewsID, NewsName only and not other items (like author name, abstract..etc.) in NewsList.jsp.

It is an efficiency and effective way for Web development.

As a result,

1. SQL Table -> Business Object and reverse

2. Change of display, change of "View" Table / Object only, no need to change any business process APIs.

3. Create "View" object, facilates to change order of properties easily and make reusability possible of such bean in other pages.

It may be a simple appraoch to handle SQL and business object mapping issue. In fact, there are theories behinds when the project grows significantly complex.

c3ka at 2007-7-7 22:47:27 > top of Java-index,Other Topics,Patterns & OO Design...