I came across the post from Jesus Rodriguez where he tries to find good reasons to convince management to use Hibernate.

[[I tried posting but it required me to create an account, also I felt that the topic might be of general interest. So I made this a separate post and included him in trackback & pingback.]]

In his case the company followed two models:
1. Contains all SQL in a single class
2. "One involves creating a helper object which exists between the domain object and a DatabaseCommand (our persistence class). The domain objects do not know how to generate SQL. They simply know that there exists a class that accepts helpers. The helper has methods like getStoreColumns() and getStoreValues() which return the columns used for inserts and their corresponding values, respectively. The helpers have direct knowledge of the domain object. The DatabaseCommand knows how to build SQL statements filling in the missing information by asking the helpers."

He has described the pros and cons of the system in his post.

Couple of thoughts & suggestions:
In general, approach one has the benefit that creating SQL code can be delegated to database specialists. Also they can optimize the code in there later on (as it is all in a single big file) to eliminate bottlenecks or simply to speed things up.
Logically though the key value is in isolating the db code. Which can also be achieved by having the classes in a single package.

The second approach as you can see is cumbersome and is rather maintenance heavy.

The key issue is that in both cases a Object relational mapping is required. In a company I worked in the past they have created and maintained ( yeah I came in after the deed was done) a home-grown ORM layer. It was a nightmare because of the following key reasons:
1. It was hard to learn and complex to use
2. Complex queries were near impossible
3. Easy queries were very time consuming to do, thereby affecting productivity
4. Because of a general Object structure (we called them BoB - business object, I jokingly named the process bobification) type checking was non-existent thereby leading to hard to find bugs
5. Debugging was royal pain

What I learned from this was that maintaining an ORM is a full-time job, specially to make it usable in a wide range of occassions and still make it easy to learn. We are not in the business of ORM. We however need the functionaility. Why bother creating and maintaining a home-grown one? The focus should be on the core competency and surely ORM is not ours. Hibernate and other ORM layers relieves you of the pains. Most of them are easy to learn. I presonally try to avoid ones which tries to create its own sql syntax as it means I have to learn yet another SQL clone. Normally they also provide a QBE type interface, saw it in hibernate too. They are the easiest to use and really help in RAD.

Everyone you hire will have to learn about a home grown ORM, whereas you may get lots of people who have used Hibernate or OJB. Also for the developers it is a reusable skill.

I rest my case.