-->
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.  [ 5 posts ] 
Author Message
 Post subject: Issues with Hibernate
PostPosted: Sat May 02, 2009 2:27 am 
Newbie

Joined: Tue Apr 07, 2009 8:48 am
Posts: 14
Location: Kerala,India
I am facing some problems with Hibnernate 3.0
Database I am using is ORACLE 10g

My application consists of more than 30 tables and a lot of relationships between them.
The application is working fine. But it takes a hell lot of time. It takes atleast a couple of minutes to retrieve something from the DB. I have set Lazy="false" in all the relationships. when i tried with lazy="true" its throwing a LazyInitializationException. I think th e application is slow because Hibernate loads all the collections by default at the startup(Correct me if I am wrong). Is there any way to stop loading all the collections at the startup itself.? I tried setting dynamic-insert="true" and dynamic-update="true" in all my HBM files. But i didnt notice any improvement.. Can anyone tell me waht should i do to improve its performance.

Guys,Any help will be greatly appreciated..
Thanks in Advance


Top
 Profile  
 
 Post subject: Re: Issues with Hibernate
PostPosted: Sat May 02, 2009 11:25 pm 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
By default, loading every entity association and collection by hibernate is lazy, so it will not load a associated entity/collection unlit required. But you have override that setting by setting lazy=false, so when you are loading any entity, it associated entity/collection are getting loaded into memory and so you are facing performance problem.

You have to find out correct lazy behavior with respect to you use case. See hibernate tutorial for that. you have to read it. without that you may face more performance problem.


Top
 Profile  
 
 Post subject: Re: Issues with Hibernate
PostPosted: Fri May 08, 2009 8:38 am 
Newbie

Joined: Tue Apr 07, 2009 8:48 am
Posts: 14
Location: Kerala,India
Thanks parmendratyagi.

I am now working with the default lazy behaviour of hibernate ie: lazy="true". The peformance has improved a lot. Its throwing an exception LaxyInitilizationException when i try to access data which has any relationships. We can rectify it by persisting the object in the session. But as my application has many tables and lot of relationships, its cumbersome to find out each and every object that needs to be persisted.But I think I am left with no another option.

Thank you all for looking into my post.

_________________
Its fun to LEARN
guru_G


Top
 Profile  
 
 Post subject: Re: Issues with Hibernate
PostPosted: Fri May 08, 2009 2:24 pm 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
The reason for the LazyInitializationException is that you try to access an association of an object outside of the session:

-- session start --
load objectA
-- session end --
objectA.getB()

If you do your session-handling manually you have to find where you close the session and either load the object earlier or close the session later.

If you could post an example where it happens it may be easier to explain.

Patrik


Top
 Profile  
 
 Post subject: Re: Issues with Hibernate
PostPosted: Sat May 09, 2009 4:45 am 
Newbie

Joined: Tue Apr 07, 2009 8:48 am
Posts: 14
Location: Kerala,India
My application has Spring so I am using HibernateTemplate which does the transaction ans session mangement by itself. As i said in my earlier post, I am trying to persist the object (which throws LazyException) in the session and its working fine now.

Thanks all for looking into the post.

_________________
Its fun to LEARN
guru_G


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