These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Which scenarios can JDBC outperform Hibernate?
PostPosted: Wed Jul 02, 2008 9:31 pm 
Newbie

Joined: Thu May 03, 2007 6:24 pm
Posts: 14
Hello Friends,

I understand hibernate's capability and benefits. but everything has its own limitations.
Still I'm sure there could be scenarios where hibernate should NOT be used at all or where JDBC programming can outperform hibernate.
Can someone please clarify this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 03, 2008 2:59 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I can give you one example since we are using a mixed approach. One part of our database is managed by Hibernate and another with plain JDBC. The application is a biological application storing information about microarray experiments. The Hibernate-managed part is used to store metadata about experiments, such as which samples has been used, which protocols was followed to prepare the samples, etc.

The JDBC-managed part is used for storing analyzed data. Each experiment gets a set of dynamically created tables that are used to store data for that experiment only. This is needed for two reasons:

* Different experiments are investigating different things. When analyzing the data they need tables that are specifically created to store their data. Eg. different number of columns, etc.

* The amount of data is huge. The starting point for an experiment can easily include 10+ millions of rows. Each step in the analysis of an experiment adds another 10+ million rows. This was before the Batch API for Hibernate existed and we couldn't have Hibernate to cache this data in the first-level cache We had a prototype that used Hibernate, but it was using way too much memory even with small data sets (< 1 million).

But we still have use for Hibernate even in the JDBC-managed part. We use Hibernate objects to programmatically build the mapping for each new table we need for an experiment. The we extract the CREATE TABLE statement and also INSERT and UPDATE statements which we use on our own JDBC connections. For SELECT operations we use our own query engine but it uses information from the Hibernate Dialect object whenever possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 1:28 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Remember, Hibernate just gets turned into SQL calls that run over JDBC under the covers, so it's all SQL and JDBC. It's apples to apples.

But can you optimize your SQL because you know your database better than Hibernate? Of course! There's always a balance.

But I haven't seen too many projects fails due to one or two extra SQL calls. Not being able to get something working, or being able to maintain a project, well, that's where projects fail. Hibernate helps you develop, maintain, and improve your applications and minimize application development lifecycle. That's pretty darn valuable.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 06, 2008 2:39 pm 
Newbie

Joined: Thu May 03, 2007 6:24 pm
Posts: 14
Thanks for the reply.

If we have the project that just dumps/writes(no read or update operation) huge data into DB, then direct JDBC can perform better than hibernate.

Can above stat is valid? If so, Can someone please give other similar scenarios?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 9:13 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I've seen very few projects where performance was a bigger issue that the development lifecycle and long term maintenance.

If you want a system that nobody can understand, nobody can maintain, and nobody can fix when it breaks, just use straight SQL calls. Don't even use JDBC. I mean, why use the JDBC bridge at all?

Think about what's most important. If all that matters is performance, there are many ways to get very high performing systems.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.