-->
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.  [ 9 posts ] 
Author Message
 Post subject: How do we call a oracle stored procedure?
PostPosted: Thu Jul 22, 2004 8:15 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
Hi,
I am new to Hibernate and in our application we have to make calls to oracle stored procedures. Does Hibernate 2 support this feature?
Any info would be appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 8:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
you can get jdbc connection from hibernate session, then call the stored procedure in jdbc

be carefull to evict objects if the stored procedure update mapped rows...

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 8:48 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
anthony wrote:
you can get jdbc connection from hibernate session, then call the stored procedure in jdbc

be carefull to evict objects if the stored procedure update mapped rows...


Thanks for the reply.
so you mean of doing something like this:
Connection conn = session.getConnection(); // get this from hibernate session
CallableStatement cstmt = conn.prepareCall(sqlcall);
cstmt.registerOutParameter(1, Types.VARCHAR);
cstmt.setString(2, key);
cstmt.execute();
retval = cstmt.getString(1);

Also, what do you mean by "be carefull to evict objects if the stored procedure update mapped rows"?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 8:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
that's exactly what i mean.

i wanted to say if you do something like:
1- get from ObjectA // ObjectA is mapped to table A
2- call SP using your code // IF SP UPDATE the row you have retrieved in table A --> myObjA is false --> you must refresh or evict it from current session

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 10:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
H2 does not support it directly, but you can do as the previous posters say or write a custom classpersister.

In H3 there are better support for providing custom sql (including stored procedures) with the built-in persisters.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 10:43 am 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
max wrote:
H2 does not support it directly, but you can do as the previous posters say or write a custom classpersister.

In H3 there are better support for providing custom sql (including stored procedures) with the built-in persisters.


Thanks for the reply. Are there any examples as to how to write the custom classpersister?

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 10:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - look at the ClassPErsister hierachy.

I also think there is a CustomPersister.java in the unit tests for your pleasure.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 12:44 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 8:09 am
Posts: 20
I have a stored procedure returning a REF_CURSOR. How do I get these results using hibernate having a custom persistor implemented.

I am using Hibernate 2.1.7
Oracle 9i


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 04, 2005 12:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
look into the source on e.g. SQLLoader (which is for querying)

...but again, you will need to do most of the "wiring" your self in H2 since it does not have support for callable statements inside the code....

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.