File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Hibernate and stored procedure 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 "Hibernate and stored procedure" Watch "Hibernate and stored procedure" New topic

Hibernate and stored procedure

azhar bharat
Ranch Hand

Joined: Jul 17, 2006
Posts: 87
Is it good to use hibernate in an application which is highly dependent on stored procedures?
Is there any disadvantage in using hibernate in such a scenario?
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

I'd say no. Hibernate can support Stored Procedures but Stored Procedures are implicitly database dependent (since thats where they live) so putting an ORM in front of them doesn't make a great deal of sense. That is unless your evental goal is to make your application portable and slowly phase out the SPs?

Hibernate wont be a great disadvantage in this case. All you are doing is replacing one type of boiler plate code (JDBC) with another (Hibenrate) to no great imediate benefit.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I'll take the opposite opinion from Paul, simply from the fact that if you have Stored Procedures without Hibernate, you will have lots of JDBC code that translates the return results from stored procedures into your Java classes, which I always find error prone and harder to maintain.

That said, there is still lots of merit to Paul's post. For instance, there are lots of ways to get better performance out of Hibernate than through a stored procedure with Caching. And I find that an all SP solution is not flexible, maintainable, and leaves you vendor locked as Paul has said.

Personally, in today's technology, those people that fight for an all SP solution are out of date.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Hibernate and stored procedure
jQuery in Action, 3rd edition