Database access in Struts -- best/common practice?
Joined: Feb 28, 2002
I have seen many Struts example applications, and the database layer is always different -- some use Torque, others use JDBC calls within the FormBean. What is the most common solution? I am not using EJB's, and I understand that Struts is designed in such a way that you can use any data model...but in all methodologies there always seems to be the solution that works 90% of the time....any suggestions?
<a href="http://www.websiteandsound.com" target="_blank" rel="nofollow">www.websiteandsound.com</a><br />"If you do what you've always done, you'll get what you've always gotten."
Joined: Jun 17, 2002
The best practice I've seen is to ensure complete seperation between the classes that access the database and Struts. In general, the best practice is to have DataAccessObjects (DAOs) access the database directly (and therefore hide the database interface completely from your application). These in turn should be called from a business object layer. Then the Struts Actions will talk to these business objects. That is by far the best layered approach.