aspose file tools*
The moose likes Object Relational Mapping and the fly likes JPA Queries Open Cursors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA Queries Open Cursors" Watch "JPA Queries Open Cursors" New topic
Author

JPA Queries Open Cursors

Ron Patel
Greenhorn

Joined: Apr 11, 2004
Posts: 18
Hello All,

I am running into a problem with very many open cursors.

I am running close to 200 database queries very quickly to fetch data. The database is configured to handle up to 300 open cursors at a time.

Over time, I am getting stack traces saying that I have reached the maximum amount of open cursors possible.

I searched many times and have not found a close method on JPA's Query method. I am using hibernate's implementation of JPA, and that has no way to close the cursor, if I cast down to the hibernate implementation class.
Has anyone ever ran into this problem before?

Another thing I am doing is opening and closing a new EntityManager around each call...so roughly 200 EntityManagers are being created and destroyed for this operation...it seems very wasteful to me.

Can anyone help?
Ron Patel
Greenhorn

Joined: Apr 11, 2004
Posts: 18
The problem seems to go away if I manually invoke the garbage collector.

This is a hack solution...there must be a better way to solve this.
Edvins Reisons
Ranch Hand

Joined: Dec 11, 2006
Posts: 364
200 queries for one use case (if I understand the situation correctly) sounds like way too many. I would expect to somehow reduce this number.
gianni barrotta
Greenhorn

Joined: Apr 21, 2008
Posts: 1
Did you eventually fix this problem?
If yes, can you give some advice?
I'm having the same problem...
Thank's.
Ron Patel
Greenhorn

Joined: Apr 11, 2004
Posts: 18
I ended up explicitly invoking the garbage collector.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

So, a simple call to System.gc(); ?

Primitive, but if it works....

-Cameron McKenzie
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JPA Queries Open Cursors