-->
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.  [ 2 posts ] 
Author Message
 Post subject: Would like opinions on stored procedure approach given here
PostPosted: Mon Mar 02, 2009 11:28 am 
Newbie

Joined: Tue Jan 27, 2009 12:43 pm
Posts: 16
I have an Oracle stored procedure that I would like to execute that performs several inserts/updates. I did not set up a REF CURSOR return type for the function as the Hibernate documentation states, but I took the following approach instead. One of the reasons that I proceeded as follows is that I need the procedure call to be in the same transactional boundary as several other Hibernate updates, and I did not want to use session.connection() to gain access to the CallableStatement because of method deprecation.

Does anybody have any criticism/comments about grabbing the SessionImplementor interface from the Session and getting the CallableStatement as follows? This all works fine in my test case. I just wanted to know if there are any potential problems with this approach.

Thank you for your feedback.

Code:

  String dbProcedureCallSql = "{? = call schema.DB_FUNCTION(?,?,?,?,?,?,?,?)}";
      
  CallableStatement dbProcedureCall =
      ((SessionImplementor) session).getBatcher()
                                                          .prepareCallableStatement(dbProcedureCallSql);
      
   dbProcedureCall.registerOutParameter(1, java.sql.Types.INTEGER);
   dbProcedureCall.setLong(2, Long.parseLong(myparms.value1()));
   dbProcedureCall.setLong(3,Long.parseLong(myparms.value2()));
   dbProcedureCall.setString(4,myparms.value3());
   dbProcedureCall.setString(5,myparms.value3());
   dbProcedureCall.setString(6,myparms.value4());
   dbProcedureCall.setString(7,myparms.value5());
   dbProcedureCall.setString(8,null);
   dbProcedureCall.setLong(9,Long.parseLong(myparms.value6()));
       
   dbProcedureCall.executeUpdate();
       
   int retVal = dbProcedureCall.getInt(1);



Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 3:41 pm 
Newbie

Joined: Mon Mar 02, 2009 9:50 am
Posts: 1
Hello all,

i urgebtky need the criticism/comments about grabbing the SessionImplementor interface from the Session and getting the CallableStatement, please help measap, i am in urgent need of the same, if any one knws a link that would do as well.

Cheers!!!


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