File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Is JDBC faster than JPA? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Is JDBC faster than JPA?" Watch "Is JDBC faster than JPA?" New topic

Is JDBC faster than JPA?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 690

I've heard that using JDBC in some circunstances can make the application faster than using JPA, because you don't need to transform the tables in entities. For an instance, I have a batch program that run a Java class to process every night at 11:30 pm. In this case using JDBC is better than JPA, concerning about performance?

Thank you.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Yes, and no.

Since this answer answers all comparative performance questions, I'll flesh it out a bit. JDBC requires more boiler plate code written so is liable to take longer to write in the first place and more effort to maintain. Given the trade off between the cost of hiring a developer against the cost of buying a more powerful computer, this is often the performance metric people look to.

JPA has things JDBC doesn't have, namely caching, so in a normal transactional application a properly implemented and tuned JPA solution should at least compare favourably with JDBC, and may be faster. However, your application is a batch processing application. This is the one area that ORMs do not do well (they were never really designed to do this job). JDBC is liable to be better here, however if this is a single database batch process, and performance is your key metric, JDBC will not compare with a 100% database solution. You might be better off with a bunch of stored procedures.

The other thing to ask when you think of performance is "do I have a performance problem"? No sense rewriting an application to run 25% faster if it completed in an acceptable time frame anyway. Step one before doing any performance tuning is benchmarking.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: Is JDBC faster than JPA?
jQuery in Action, 3rd edition