aspose file tools*
The moose likes JDBC 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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is JDBC faster than JPA?" Watch "Is JDBC faster than JPA?" New topic
Author

Is JDBC faster than JPA?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hi,

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.


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Paul Sturrock
Bartender

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: http://aspose.com/file-tools
 
subject: Is JDBC faster than JPA?