-->
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: Closing cursors opened by StoredProcedureQuery
PostPosted: Wed May 11, 2016 5:00 am 
Newbie

Joined: Wed May 11, 2016 4:41 am
Posts: 1
Hello.
I'm using Hibernate 4.3.7.
When I'm calling StoredProceduredQuery multiple times in one transaction, I've received error "ORA-01000: maximum open cursors exceeded".
Apparently, each call of StoredProceduredQuery.execute opens new cursor. But to close this cursor, I need to use this code:
Code:
query.unwrap(ProcedureOutputs.class).release();

Maybe StoredProceduredQuery should have public method release for this purpose? Or maybe I'm doing something wrong?


Top
 Profile  
 
 Post subject: Re: Closing cursors opened by StoredProcedureQuery
PostPosted: Mon May 16, 2016 8:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The CallableStatement remains open for the duration of the currently running transaction, and it gets closed when the LogicalConnectionManagedImpl object is closed.

If you are creating many StoredProceduredQuery, I guess you can run into this issue that you mentioned.

What you need to do is to call the release method like this:

Code:
StoredProcedureQuery query = entityManager
.createStoredProcedureQuery("count_comments")
.registerStoredProcedureParameter("postId", Long.class, ParameterMode.IN)
.registerStoredProcedureParameter("commentCount", Long.class, ParameterMode.OUT)
.setParameter("postId", 1L);

try {
   query.execute();
   Long commentCount = (Long) query.getOutputParameterValue("commentCount");

   assertEquals(Long.valueOf(2), commentCount);
} finally {
   query.unwrap(ProcedureOutputsImpl.class).release();
}


For more details, check out this article.


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.