-->
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: Need help with making a query effiently in HQL
PostPosted: Tue Jun 28, 2005 1:39 pm 
Newbie

Joined: Tue Jun 28, 2005 12:30 pm
Posts: 1
Location: Irvine, CA
Hi everyone,

I'm having trouble figuring out a good way to efficiently do a query. I have a table that is being used to periodically log server status information. One of the queries I want to do is to get the most recent entry for each server. In sql I would have done this with a temporary table. For a simple example let's say my object has three member variables, host id, timestamp, and status. In sql I would query:

Code:
select HOSTID, TIME_STAMP, STATUS from STATS, ( select HOSTID, max(TIME_STAMP) as MAXTS from STATINFO group by HOSTID ) as FOO where STATS.HOSTID = FOO.HOSTID and STATS.TIME_STAMP = FOO.MAXTS


Obviously, I could do this query in sql, but I really don't want to. The actual object I need to query is much more complicated then the one in my example. It has objects, and sets and maps of objects as member variables, and those objects have other objects. In all there are 12 tables for this one object and all its sub-objects.

So I would appreciate any insight anyone has on a way to do this efficiently with hql.

Thanks,
Ed


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.