-->
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: how can i get both entity and scalar from hibernate query?
PostPosted: Wed Jan 19, 2011 12:03 am 
Newbie

Joined: Tue Jan 18, 2011 11:56 pm
Posts: 1
this may be a noob question and i have dig through this for some time , most tutorial tell me how to get the data in one entity but what if there is another scalar (and it come from another table) ? here is my code

Quote:
String sql = "select A.*,sum(B.something)" +
" from A " +
" left join B " +
" on A.ID = B.ID " +
" group by B.something";
List l = this.getSession().createSQLQuery(sql).addEntity("a",A.class).addScalar("B.something", Hibernate.LONG).list();


then how can i iterate through l to get Entity A and sum value of B ?


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.