-->
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.  [ 3 posts ] 
Author Message
 Post subject: HQL
PostPosted: Thu Jan 26, 2006 1:18 pm 
Newbie

Joined: Thu Jan 26, 2006 1:10 pm
Posts: 6
Hi All,

I am a newbie to Hibernate.

How can I convert the following SQL into Hibernate Query Language(HQL):

SELECT a.register, c.descr as grpdescr,
requested=isnull(Sum(b.amt_requested),0),
allotted=isnull(Sum(b.amt_allotted),0)
into #temp_budget
FROM header a, line c where a.id=c.id

Any help greatly appreciated.

Thanks,

Sam


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 8:33 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
this isn't sql - this is any procedural language


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 10:29 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
HQL is (primarily) used for mapping returned values to java classes. That bit of SQL isn't returning any values. HQL is not appropriate in this case.

Just in case you weren't aware of this: don't use "select ... into ..." in production code. Because it creates a table at the same time as doing a select, it locks several important system tables (sysobjects, syscolumns, etc.) for the duration of the select. This essentially freezes your entire database for the duration of the query. You're far better off doing a create table then an insert ... select ...


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