Hibernate and JDBC performance?
JDBC will always give better performance as compared to Hibernate for most of the database vendors. You can check the comparison made as given in the link below. He concludes that Hibernate is fast when querying tables with less rows else JDBC is way better:
http://phpdao.com/hibernate_vs_jdbc/
Another good performance stats can be found in Hibernate forum discussion at https://forum.hibernate.org/viewtopic.php?f=1&t=931708
It states the following order of performance hit taken due to use of Hibernate (please note that this can be improved by tuning Hibernate to one's needs:
Objects: 8 - Hibernate: 10ms / Direct JDBC: 10ms = Ratio: 1.0 Objects: 16 - Hibernate: 10ms / Direct JDBC: 0ms = Ratio: Infinity Objects: 64 - Hibernate: 20ms / Direct JDBC: 10ms = Ratio: 2.0 Objects: 256 - Hibernate: 150ms / Direct JDBC: 30ms = Ratio: 5.0 Objects: 512 - Hibernate: 210ms / Direct JDBC: 40ms = Ratio: 5.25 Objects: 1024 - Hibernate: 410ms / Direct JDBC: 70ms = Ratio: 5.857143 Objects: 2048 - Hibernate: 681ms / Direct JDBC: 180ms = Ratio: 3.7833333
The choice of Hibernate over JDBC and SQL queries is not because of the performance, but because of reasons mainly object persistence and database independence in terms of not writing database specific queries. You can read the following PDF guide to get a better view:
- http://www.mindfiresolutions.com/mindfire/Java_Hibernate_JDBC.pdf