-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem in group by and order by with oracle10g
PostPosted: Thu Aug 07, 2008 6:38 am 
Newbie

Joined: Thu Aug 07, 2008 3:29 am
Posts: 2
I am using query given below in hibernate with oracle10g,

"SELECT OcspTransactionLogs.relyingPartyIp,OcspTransactionLogs.relyingPartyId,count(OcspTransactionLogs.id)
FROM OcspTransactionLog OcspTransactionLogs
WHERE OcspTransactionLogs.responseStatus = 'successful'
GROUP BY OcspTransactionLogs.relyingPartyIp,OcspTransactionLogs.relyingPartyId
ORDER BY count(OcspTransactionLogs.id) desc"

It properly grouping records without "order by clause",as I order it by count(...), It fill first record data in "OcspTransactionLogs.relyingPartyIp and OcspTransactionLogs.relyingPartyId" for the subsequent records,

e.g,

True grouping records are as,

192.123.12.13 N/A 10
192.123.12.13 testData 30

But when order by clause is used as in above query, records will be,

192.123.12.13 N/A 30
192.123.12.13 N/A 10

What can I do to get exact records by using order by clause,

Needs your urgent help.

Thanks.
Naeem


Top
 Profile  
 
 Post subject: Re: Problem in group by and order by with oracle10g
PostPosted: Thu Aug 07, 2008 7:21 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
1. Determine who is the culprint.

run the sql statement in a the sql tool of your choice directly against the database. Preferably sqlplus. Check if the problem shows up. If yes continue under oracle.

Otherwise continue under Hibernate


Oracle: Throw away any Index on the affected tables, rebuild the table, recreate the indexes and try again. If it doesn't fix the problem contact oracle support.


Hibernate: Post the exact code resulting in the query (both variations).
Enable debugging to see the exact sql statements issued and the bind parameters/results returned.
Post your findings here

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: Problem is on Hibernate end
PostPosted: Thu Aug 07, 2008 7:54 am 
Newbie

Joined: Thu Aug 07, 2008 3:29 am
Posts: 2
In oracle client this query working fine,

If I run query in application using Hibernate 3.0

"SELECT OcspTransactionLogs.relyingPartyIp,OcspTransactionLogs.relyingPartyId,count(OcspTransactionLogs.id)
FROM OcspTransactionLog OcspTransactionLogs
WHERE OcspTransactionLogs.responseStatus = 'successful'
GROUP BY OcspTransactionLogs.relyingPartyIp,OcspTransactionLogs.relyingPartyId"

The above query working fine (shows true results).

AS I add following order by clause to above query then it do order but it duplicate the results in all records for fields included in group by clause.

ORDER BY count(OcspTransactionLogs.id) desc

It seems there is some issue of hibernate with oracle10g.

Thanks,

Best Regards,
Naeem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 07, 2008 9:12 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Post the exact code resulting in the query (both variations).
Enable debugging to see the exact sql statements issued and the bind parameters/results returned.
Post your findings here

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


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