-->
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.  [ 6 posts ] 
Author Message
 Post subject: AnnotationConfiguration buildSessionFactory()
PostPosted: Sat Apr 28, 2007 9:38 pm 
Newbie

Joined: Sat Apr 28, 2007 9:05 pm
Posts: 3
Greetings,

I'm using hibernate 3.2 and I have around 90 objects that I'm persisting to a Postgres database and I'm working in an Eclipse environment. I have a rather complex relationships between the objects that I have been able to successfully map using annotations. However, when testing the persistance of all the objects at once (instead of one relationship at a time through unit testing), I get a OutOfMemoryException: Java heap space when I call the AnnotationConfiguration.configure().buildSessionFactory().

Now I can solve this problem by increasing the heap size. But I've noticed that when the buildSessionFactory() is called, it is initializing a copy of all my objects that are being persisted and I believe this is what is causing the problem. When I switched back to my XML mapping structure, those objects were not being initialized by buildSessionFactory().

So I basically have 2 questions. Is there a way I can stop buildSessionFactory() from initializing copies of all my (persistable) objects? And is an increased memory usage the price of using annotations?

Any help is gratefully appreciated!


Top
 Profile  
 
 Post subject: Re: AnnotationConfiguration buildSessionFactory()
PostPosted: Tue May 01, 2007 3:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
rje0929 wrote:
Now I can solve this problem by increasing the heap size. But I've noticed that when the buildSessionFactory() is called, it is initializing a copy of all my objects that are being persisted and I believe this is what is causing the problem. When I switched back to my XML mapping structure, those objects were not being initialized by buildSessionFactory().

So I basically have 2 questions. Is there a way I can stop buildSessionFactory() from initializing copies of all my (persistable) objects? And is an increased memory usage the price of using annotations?


can you be a bit more specific? There should be no fundamental diff between annotations and xml.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:51 pm 
Newbie

Joined: Sat Apr 28, 2007 9:05 pm
Posts: 3
To test my theory, I placed a System.out.println in the constructors of my objects. When I called the AnnotationConfiguration.conifgure().buildSessionFactory() method, I could see each object printing out values while the session factory was being built. But when I used a normal Configuration.configure().buildSessionFactory(), I did NOT observe my objects printint out values from their respective constructors.

I hope this helps to clear things up.

Thank you in advance for any light you can shed on this.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 3:55 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
print the stack trace please

new Exception().print...

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 4:02 pm 
Newbie

Joined: Sat Apr 28, 2007 9:05 pm
Posts: 3
Unfortunately, the buildSessionFactory() is not printing a stack trace. It only gives me a OutOfMemoryException: Java heap space printed out. I only see this when I have a large number of objects (100+). Otherwise it works with no issues.

Is there a way that I can get buildSessionFactory() to print a stack trace? Would that be more helpful?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 01, 2007 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I mean print the stack trace in the constructor so we can find where the object is instanciated :-)

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.