MVC & ResultSet...

Hi all,

Why one should use a Collection object which contains javabean objects (one for each for each database row) over ResultSet object in MVC? What are the advantage on not using ResultSet in MVC at presentation layer?

I hope my question is clear enough.

Cheers.

[290 byte] By [jini4javaa] at [2007-11-27 10:21:47]
# 1

1: Proper utilization of resources - passing the result set to the presentation layer requires keeping the connection open which is expensive. Also if increases the possible that with enough traffic you would run out of connections.

2: Ease in maintenance - At some point you'll need to close the result set, statement and connection. Passing the result set to the presentation layer makes this difficult and error prone. Also keeping access to the result set in one place makes it easier to adapt to changes to the database (eg column name changes)

3: Extendability - If at a later date it is decided to change how the application retrieves data (eg decide to use Hibernate or a web service). Refactoring the code in response to such a change can be done easily in a well structured DAO layer. If you are passing the result set to the presentation layer you would have to rewrite the entire application.

tolmanka at 2007-7-28 17:12:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi,

That is really useful. I appreciate your help.

You mention Hibernate...I know how it works and I implemented it for one application, but i am enable to convince my colleagues to use it in the following scenario....

We are involved in developing small application for only criteria based search database web functionality... In an year, we normally build 8 small applications like this. We have already adopted Struts MVC... and I would like to use Hibernate instead of JDBC on data access layer. So, what do you think about benefits of hibernate in this sort of hetrogineous environment? Should I go for it?

Thanks.

jini4javaa at 2007-7-28 17:12:04 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...