views:

129

answers:

1

Hello,

I have been using Hibernate + HSQLDB on my desktop for developing a database adapter for my application. For legacy reasons, the IDs are generated by the application as strings. All was working fine then.

Now, we have a pre-prod database, with a bit more than a million records. I had to do some changes (e.g. identifier too long) on the Hibernate side, but nothing major.

That is, until I got to this problem. When I try to start my application on the pre-prod server, Hibernate starts making a gazillion queries, which eventually end up in a OutOfMemoryError: Java heap space. Increasing the heap max is not helping.

I have disabled C3PO cache settings and disabled hibernate.hbm2ddl.auto. I don't know why it is making these queries, and I don't know how to disable them.

Can anyone help me??????

+1  A: 

You told Hibernate to fetch eagerly. So when you load the first object, Hibernate starts to fetch all related objects, too.

You must set all unnecessary relations to fetch=LAZY.

Aaron Digulla
That's good. I disabled all the fetch options (thus letting Hibernate figure it out with its defaults) and I don't have this situation.However, I have blocking behaviour now.:(
mlaverd
You must find a balance between lazy and eager fetching. And you must make sure you use the correct transaction nesting. Good luck debugging this. I'd usually suggest test cases but it's hard to come up with tests for deadlocks.
Aaron Digulla