-->
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: How to deal with syntax differences calling stored procedure
PostPosted: Thu Mar 15, 2007 12:03 pm 
Newbie

Joined: Thu Mar 15, 2007 10:11 am
Posts: 19
Location: Dallas
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2.1
Name and version of the database you are using:
Oracle 10g, MySQL 5.1

Problem Description:

We use oracle’s connect by queries to get all the children of a given node. Now we are trying to make our application database independent by trying to push all the database specific code (connect by, analytical function etc.) to stored procedures and make them return result sets.
Hibernate’s documentation says to use the below syntax in the hibernate-mapping file to call a stored procedure using named query.
Code:
{?=call GET_ALL_CHILDREN(?,?)}

But the syntax is only true for Oracle database in my case. I tried using the same syntax for MySQL database and it throws exceptions. When I change the syntax to
Code:
{call GET_ALL_CHILDREN(?,?)}
everyting works fine in MySQL.

My questions are:
1) Is there a way I can make my application database independent?
2) Is there a different approach I need to take to attain database independence?

I might ask some more question as I remember.

Thanks

Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 12:22 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Don't know where you got the idea that stored procedures would make your application database-independent, because it does the exact opposite. The key is to either abstract away database-specific calls and syntax by using an ORM (which I assume you know of since you are here), or make the JDBC calls totally generic (e.g. ISO99) and live with the performance degradation.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 12:41 pm 
Newbie

Joined: Thu Mar 15, 2007 10:11 am
Posts: 19
Location: Dallas
Thanks for replying so quick.

When i mean database independent, it means to make our java application code database independent. The reason i choose stored procedures is because it will be like abstraction layer to the application. I will have two version of stored procedures one in Oracle and one in MySQL and take full advantage of that particular database (e.g. analytical functions in Oracle) in the stored procedure. I don't want any performance degradations.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 12:52 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
As you have already found out, calls to stored procedures are highly dependent on the database platform, as the calls have little to no standards across vendors. Now, you would be stuck with abstracting the stored procedure calls to an interface and implementing the interface for each database platform. Ick!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 5:47 pm 
Newbie

Joined: Thu Mar 15, 2007 10:11 am
Posts: 19
Location: Dallas
Could you please explain more clearly when you mean "The key is to either abstract away database-specific calls and syntax by using an ORM"

Thank you.


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.