Oh by the way, I've found the new Java6/JDBC4 DataSet mechanism quite interesting and elegant too. Being able to define queries elegantly like this is quite handy, if you can use Java6 in your current project:
interface LoanAppDetailsQuery extends BaseQuery {
@Select(sql="SELECT * from LoanDetails
where borrowerFirstName= ?1 and borrowerLastName= ?2")
DataSet<LoanApplication> getLoanDetailsByBorrowerName(String borrFirstName,
String borrLastName);
}
It's somehow similar to Groovy's jdbc tricks. As far as I know there's no caching or lazy loading or such sophisticated features present in DataSet at the moment, but I kinda like the mechanism :)
I remember I created a similar mechanism for a fairly huge
project years ago along the same lines. My old EedeNarmafzar ex-colleagues in this mailing list will remember that and specially GenericFinder ;-) Quite interesting 2-3 subsystems of the project were using Hibernate and eventually Hibernate was replaced to use this custom mechanism! It IS true that most people already know SQL and it's easier for them to handle SQL.
Personally for me, neither SQL nor HQL is easy at all! I've personally seen Hibernate succeed in huge projects with not much of a problem, and I've seen it fail too. Same about SQL. My biggest problem with putting more emphasize on SQL is that most projects are organic beasts! They change, they grow. The
data model and domain model both change. Changing a domain model is easier than tracking down this and that field here and there in different SQLs. Java objects are simply way more refactorable. Honestly I haven't seen many people who do refactor their code anyway! But I do. So in most cases they just ask themselves "WTF is he talking about?!" and keep on living in their cozy hacky codes ;-)