Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Queries Open Cursors

 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you eventually fix this problem?
If yes, can you give some advice?
I'm having the same problem...
Thank's.
 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ended up explicitly invoking the garbage collector.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, a simple call to System.gc(); ?

Primitive, but if it works....

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic