-->
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.  [ 8 posts ] 
Author Message
 Post subject: Bug or Something else for Statistics in Hibernate3?
PostPosted: Mon Oct 03, 2005 12:42 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

3.0.5

Code :

Code:
Statistics stats = sessionFactory.getStatistics();
String[] queries = stats.getQueries();
       
//queries statistics
if (queries != null && queries.length > 0)
{
    for (int i=0;i<queries.length;i++)
    {
        .......


Full stack trace of any exception that occurs:

no exception , but queries is NULL

Solution:

i trace the code and found that getQueryIdentifier() in org.hibernate.loader.Loader doesn't be implemented.

i code it to :

Code:
protected String getQueryIdentifier()
{
     return getSQLString();
}


and then , statistics is running good.

what i wonder is why getQueryIdentifier() is not completed and what i impelemennts is right?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 3:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Loader is not used when you execute queries - thus it is returning null to not let it be counted in the querystatistics.

There are separate stats for loading objects/collection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 5:21 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
so , if getQueryIdentifier() return NULL , how can i getQueries()?

what i simplly wanna to do is static the queries system ran before and see the details such as ExecutionAvgTime,ExecutionMinTime,ExecutionMaxTime

but if identifier is return NULL , i can't get query from Statistics ......


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 5:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What Max meant to say is that its null on the abstract superclass so as not to count fetches (we do not consider them to be queries). It is defined for HQL and native SQL queries.

It is not defined for Criteria queries, because they don't have a string representation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 5:31 am 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
ok , i know you guys's purpose now

thanks any way


Top
 Profile  
 
 Post subject: Actually I'm running into same issue.
PostPosted: Sat Oct 29, 2005 4:47 pm 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
Actually I'm running into same issue. Gavin says queries don't have string representation but I don't understand that because they do have a sql string representation (sql in CriteriaLoader for example, inherited from OuterJoinLoader ). Basically I need to collect statistics for every query run similar to original poster and see statistics. Is that not possible.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 29, 2005 10:33 pm 
Beginner
Beginner

Joined: Sat Nov 01, 2003 6:14 am
Posts: 30
it's possible but u should edit the code of Hibernate by self

edit org.hibernate.loader.Loader :

Code:
protected String getQueryIdentifier()
{
     return null;
}


to

Code:
protected String getQueryIdentifier()
{
     return getSQLString();
}


then every sql u can static


Top
 Profile  
 
 Post subject: Of course i know I could.
PostPosted: Sun Oct 30, 2005 2:56 am 
Regular
Regular

Joined: Thu Sep 09, 2004 6:46 pm
Posts: 96
Of course i know I could. But I want to be in a better place where I wouldn't have to ask them to do this.


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