Quote:
Which is more faster, direct database connection or database through Hibernate?
Well, intelligent, direct database access with optimized queries by someone who has intimate knowledge of SQL and the database along with SQL optimization techniques, and can cache results as effectively as Hibernate does, well, they might write an application that might be faster.
Of course, at runtime, Hibernate just does SQL calls over JDBC, so, when all is said and done, it's really the same technology. But of course, someone who can write optimized SQL can make it run faster.
Of course, I'm not sure why anyone is making development decisions based largely on performance. I've never seen an application failed to be built because when it was complete, it met 100% of the requirements but was a millisecond too slow. I've seen alot of projects fail because the technology was too difficult to understand. And I've seen alot of projects fail because developers couldn't understand the way previous developers wrote code.
Most projects fail because the development team doesn't have the skills or the knowledge to implement the task. And on top of that, the biggest cost of any application is long term maintenance, not hardware. Any good manager should know that. Technologies like Hibernate make difficult applications easier to develop, and they can be developed way faster than ones developed using straight JDBC. Also, they are much easier to maintain and manage, as the domain model can change, but no changes need to be made to JDBC or SQL calls. Furthermore, Hibernate is easy to understand. When that MIT genius that wrote all the SQL calls that nobody understands leaves the project to work for a competitor, you'll never find anyone to replace her. But if you used Hibernate, you'd have a vast sea of qualified professionals to help out.
But, if all that matters is performance, and long term cost and maintainability are not of a concern, but all means, just use straight JDBC calls. If you know what you're doing and have the skills, you might just gain several milliseconds per call. But then again, you might not.