-->
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: OpenCursors Issue
PostPosted: Tue Apr 15, 2008 1:35 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0

Deal All,

We are facing this issue where RefCursors in Oracle 10g are not closing. The code used for invoking the stored procedures is very simple....

Code:

Session session = getSession();
      Connection connection = session.connection();
      CallableStatement callableStatement = null;
      ResultSet resultSet = null;
      List clientIdList = new ArrayList();
      
      try{          
         callableStatement = connection.prepareCall("{ ? = call DATA_OWNER.PT_GETDATA_VALUES.USP_GET_CLIENT() }");         
         callableStatement.registerOutParameter(SystemConstants.P_OUT, oracle.jdbc.driver.OracleTypes.CURSOR);
         
callableStatement.executeQuery();
resultSet = (ResultSet)callableStatement.getObject(SystemConstants.P_OUT);                  
//Iterate over resultSet and fetch all the clientIds
while(resultSet.next()){
      Client client = new Client();
      client.setClientId(new Integer(resultSet.getString(SystemConstants.CLL_ID)));
      client.setClientName(resultSet.getString(SystemConstants.CLL_CLIENT_NAME));
            clientIdList.add(client);
            
         }
      } catch (Exception e) {
         e.printStackTrace();
      } finally {
         try {
            resultSet.close();
            callableStatement.close();
            connection.close();
            session.close();
         } catch(Exception e) {}
        }
      
      return clientIdList;



I believe, as we are closing the resultSet, callableStatement, connection and to session as well, the refcursor should be closed.

The problem I am facing now is that the PLSQL Developers and DBAs believe, it is because of the way Hibernate obtains the session object that the cursors remain open.

I am sure this is not the case, but it is difficult to convince my peers.

I would also like to mention that the Database is layered...i.e. the Java app talks to one schema(say parent) and this schema then invokes stored procedures in the child schema. This means that the Java App never invokes Stored Procedure in the child schema.

Can anybody please give me pointers as to where could the problem be? Its pushing to an extent now that we are being asked to stop using Hibernate.

Shardul.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 15, 2008 4:55 am 
Beginner
Beginner

Joined: Fri Sep 08, 2006 7:29 am
Posts: 36
The issue was resolved using Oracle Datasource. Everything works finr, just use the DS.

_________________
Shardul
Please Rate.


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.