-->
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.  [ 7 posts ] 
Author Message
 Post subject: Hibernate performance Isssue
PostPosted: Mon Mar 19, 2007 5:33 am 
Newbie

Joined: Fri Mar 31, 2006 7:46 am
Posts: 17
Hi,

In my Persistence Class, I have used

Session session = HibernateUtil.getSessionFactory().getCurrentSession();

in all the methods(save,get,update).

My main java class that calls this class has a call like
PersistenceManaget.get(parm1,parm2),
which calls Hibernate Util, and gets a session and then it goes to this PersistenceManager class. Queries take lot of time to run.
All my queries are written in hbm_xml.

Please suggest something...


Top
 Profile  
 
 Post subject: Re: Hibernate performance Isssue
PostPosted: Mon Mar 19, 2007 9:32 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
pams wrote:
Please suggest something...


use a profiler

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject: Performance Issue in HibernateUtil
PostPosted: Tue Mar 20, 2007 4:01 am 
Newbie

Joined: Fri Mar 31, 2006 7:46 am
Posts: 17
Hi,

Following is my HibernateUtil.java class.


public class HibernateUtil
{
private static final SessionFactory sessionFactory;
private static String CONFIG_FILE_LOCATION = "cfg path";
private static final Configuration cfg = new Configuration();
static {
try {
// Create the SessionFactory from hibernate.cfg.xml
cfg.configure(CONFIG_FILE_LOCATION);
sessionFactory = cfg.buildSessionFactory();
System.out.println(sessionFactory);
} catch (Throwable ex) {
ex.printStackTrace();
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static SessionFactory getSessionFactory() {
return sessionFactory;
}

}



When the code comes to sessionFactory = cfg.buildSessionFactory(); line. It takes around 1 minute, which is a big issue.
How do I reduce this time? What exactly should be done, so that it takes few seconds...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 5:08 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
hi pams,

once application run you are not going to rerun that code .It is in static block. It should not be very big issue.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 5:57 am 
Newbie

Joined: Fri Mar 31, 2006 7:46 am
Posts: 17
Yes true, but in my PersistenceManager class:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();

is there, to fetch the session, but it also takes time.... In all, to run a single query which can be run in AS400 in seconds, here it takes 1.30 mins.. which you see isa long time..

In my hbm.xml, I have composite Ids but the database mapping is missing, I want to set lazy="true". Can u suggest me as to how can I give
that without mapping?? I mean, is it possible??


Top
 Profile  
 
 Post subject: hibernate performance issue
PostPosted: Thu Mar 22, 2007 8:54 am 
Newbie

Joined: Fri Mar 31, 2006 7:46 am
Posts: 17
Hi,

As you know, all my queries are in hbm.xml and in my main class,
I simply call PersistenceManager.get(parm1,parm2), in which I have
used
Query q1 = session.getNamedQuery("QueryName");

List result = q1.list();

This list internally calls nullSafeSet and nullsafeget methods of
my user created type class. Whenever, it reaches:

nullSafeSet : it takes 389 milliseconds
nullsafeGet : 406 milliseconds
finally result : 389 milliseconds

In all more than 1 second, which is quite high...
Please help me out as to how to tackle with this problem......


Top
 Profile  
 
 Post subject: hibernate performance issue
PostPosted: Thu Mar 22, 2007 8:54 am 
Newbie

Joined: Fri Mar 31, 2006 7:46 am
Posts: 17
Hi,

As you know, all my queries are in hbm.xml and in my main class,
I simply call PersistenceManager.get(parm1,parm2), in which I have
used
Query q1 = session.getNamedQuery("QueryName");

List result = q1.list();

This list internally calls nullSafeSet and nullsafeget methods of
my user created type class. Whenever, it reaches:

nullSafeSet : it takes 389 milliseconds
nullsafeGet : 406 milliseconds
finally result : 389 milliseconds

In all more than 1 second, which is quite high...
Please help me out as to how to tackle with this problem......


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