OK. Not sure if this is the correct form for this question, but here goes. If your trying to stick to a MVC model and are accessing a DB in a bean, how do you return the result set? do you pass a arrayList as a return value of the function that you called in the bean? If so how does this affect performance? Or do you use some other method? Thanks
I would say that it really depends on how object-oriented you want your application to be. At a very basic level, you could return a javax.sql.RowSet. Or you can create actual objects that reflect the data being retrieved (Order, MailItem, etc). MVC doesn't really say in what format you should pass data from the controller to the model, and from the model to the view--it just says that you should separate these areas with a clear interface so that things go better for you in the long run. So, whether you return your model as a giant array, or wrapped into objects, you will still have what we call a MVC application. As for performance, things can go a little crazy with database calls, especially remoted, but that really depends on the behavior of your application. I would recommend going through some of the J2EE design patterns and see if any apply to what you are doing. I think they have some that apply to database issues. I'm going to stop rambling. I hope this helps you some. Feel free to expound on your inquiry for some additional help.
Answers you receive on this really will depend on the individual. A lot of taglibs out there take ResultSet and the like as parameters. You can pass back this kind of object to completely decouple your db from your business logic. My preference is when I am returning multiple rows from a database, I prefer to return ArrayLists of Beans.
Joined: Feb 24, 2004
so let me see if I have this right. In a bean you query you DB. The results are then put in a arrayList which is then returned to app where you handle the display? Also what are some good sites/books to learn more about MVC. I just started writing JSP pages and discovered that I am not following best practices. I want to learn more about MVC and taglibs but am having a hard time finding good info geared for a beginner.