-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate ORDER BY behaves differently than database!! HELP!
PostPosted: Thu May 04, 2006 1:21 am 
Beginner
Beginner

Joined: Tue Jun 21, 2005 1:45 pm
Posts: 38
When I execute below query in SQL Query analyzer, the resultset order that I get are different than when I run it thro Hibernate.

Below is the SQL defined in mapping file.

<sql-query name="InsuredEntityAddl.selectInsuredEntityAddl">
SELECT InsuredEntityAddl.InsuredEntity_UID, InsuredEntityAddl.Ins_Ent_Ver_NBR, InsuredEntityAddl.InterestType_CDE, InsuredEntityAddl.InterestSeq_UID, InsuredEntityAddl.InsName_Type_CDE, InsuredEntityAddl.InsName_Seq_UID, InsuredEntityAddl.Insured_Other_NME, InsuredEntityAddl.Policy_NBR, InsuredEntityAddl.Certificate_NBR, InsuredEntityAddl.Policy_Version_NBR FROM InsuredEntityAddl INNER JOIN PolicyChange on InsuredEntityAddl.Policy_NBR = PolicyChange.Policy_NBR and InsuredEntityAddl.Certificate_NBR = PolicyChange.Certificate_NBR and InsuredEntityAddl.Policy_Version_NBR = PolicyChange.Policy_Version_NBR WHERE InsuredEntityAddl.Policy_NBR =:Policy_NBR AND InsuredEntityAddl.Certificate_NBR =0000 AND InsuredEntityAddl.InsuredEntity_UID =:InsuredEntity_UID AND InsuredEntityAddl.Ins_Ent_Ver_NBR =1 AND InsuredEntityAddl.InterestType_CDE = 'N' AND InsuredEntityAddl.InsName_Type_CDE IN ('L','S') AND InsuredEntityAddl.InterestSeq_UID =0 AND (InsuredEntityAddl.Policy_Status_CDE IN ('C','E','X') or (InsuredEntityAddl.Policy_Status_CDE = 'D' and PolicyChange.Change_Eff_DTE >'2006-06-01 00:00:00.0' and (PolicyChange.NVOEndorsement_NBR = 0 or PolicyChange.NVOEndorsement_NBR IS NULL))) ORDER BY InsuredEntityAddl.InsName_Type_CDE desc, InsuredEntityAddl.InsName_Seq_UID
</sql-query>


InsName_Seq_UID is a small int and it is possible to have duplicate values in both InsName_Type_CDE and
InsName_Seq_UID. So even though hibernate records are in different order than sql query analyzer, it is still sorted per above criterial. only difference is if 2 rows are with the same InsName_Seq_UID and InsName_Type_CDE, then their position in the output is different in Hibernate and SQL Query analyzer.

I'm using MS SQL Server 2000.

Kindly help me to resolve this issue if you know the solution..

Thx..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.