-->
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: session.createQuery() problem
PostPosted: Wed Sep 05, 2007 4:58 am 
Newbie

Joined: Wed Sep 05, 2007 4:30 am
Posts: 1
WHY THIS CODE:

StringBuffer queryString = new StringBuffer();
queryString.append("select lr.id, count(lre.leadingRecord) ");
queryString.append("from LeadingRecord lr ");
queryString.append("left outer join lr.leadingRecordErrors lre ");
queryString.append("group by lr.id ");
queryString.append("order by lr.id asc");

Session session = HibernateUtilSUNCE.getSession();
try {
Query query = session.createQuery(queryString.toString());
query.list();
}...

GENERATE FOLLOWING SQL:

select
leadingrec0_.ID as col_0_0_,
count(leadingrec1_.LRER_LDRE_ID) as col_1_0_
from
LEADING_RECORD leadingrec0_,
LEADING_RECORD_ERROR leadingrec1_,
LEADING_RECORD leadingrec2_
where
leadingrec0_.ID=leadingrec1_.LRER_LDRE_ID(+)
and
leadingrec1_.LRER_LDRE_ID=leadingrec2_.ID
group by
leadingrec0_.ID
order by
leadingrec0_.ID asc

INSTEAD DESIRED SQL GENERATED BY HIBERNATE TOOLS HQL EDITOR:

select
leadingrec0_.ID as col_0_0_,
count(leadingrec1_.LRER_LDRE_ID) as col_1_0_
from
LEADING_RECORD leadingrec0_,
LEADING_RECORD_ERROR leadingrec1_
where
leadingrec0_.ID=leadingrec1_.LRER_LDRE_ID(+)
group by
leadingrec0_.ID
order by
leadingrec0_.ID asc

SO I GET RESULT SET SOMETHING LIKE THIS:

[2003,2]

INSTEAD DESIRED ONE LIKE:

[2000,0]
[2001,0]
[2002,0]
[2003,2]
[2004,0]


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.