This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes JPA and JDBC, Which one is Performance efficient Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA and JDBC, Which one is Performance efficient" Watch "JPA and JDBC, Which one is Performance efficient" New topic

JPA and JDBC, Which one is Performance efficient

Shayan Shah

Joined: Aug 28, 2009
Posts: 25

I am working on an application that needs to be highly performance efficient. We will be having heavy data stored in data bases. And will be having hundreds of requests per minute and for each request will interact with database.

Now JPA ease us from writing SQL and many more, but in this sceneraio, will JPA be that efficient as it adds an extra layer over the JDBC and generates SQL which we can write directly?

Also we have another module that heavily communicates with database, will JPA be performance efficient or JDBC in this case?

James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Most JPA providers are highly optimized and provide many performance features such as caching, batch writing, sequence preallocation, batch fetching, parametrized SQL and many others.

If you had perfectly optimized JDBC and application code, and cached any cacheable data yourself, and took full advantage of every optimization offered by your JDBC driver and database, then you would have better performance than JPA. However most applications are not perfectly optimized, and the more complex the application to more likely the issues. JPA allows easy configuration and optimization of a persistent application, which can lead to better performance. JPA also allows you to spend less time on persistence, so you have more time to spend optimizing your application.

Your performance requirements do not seem like much, so I don't see any issue in using JPA.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Shayan Shah wrote:Also we have another module that heavily communicates with database, will JPA be performance efficient or JDBC in this case?Thanks

Impossible to tell. It depends on the requirements of the application.

It is possible to write good/bad JPA and good/bad JDBC. It's hard to compare properly.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
I'm also very interested in this topic.

I would like to kindly ask you about JPA performance myself, particularly about the EclipseLink implementation. The Question is: Is it normal for an Entity Manager to go to sleep so to speak. The scenario I'm worried about is related to that, I noticed that If I leave the Container (OC4J in this case) inactive for a long period of time and then suddenly make an Insert operation, it takes way too long. Checking the Container Console shows that apparently the Resource(Entity Manager) is instantiated again after a long period of inactivity, and this causes a huge delay.

Is this a big concern for a production environment ?


I agree. Here's the link:
subject: JPA and JDBC, Which one is Performance efficient
It's not a secret anymore!