-->
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.  [ 2 posts ] 
Author Message
 Post subject: how to write a HAVING query
PostPosted: Wed Jun 28, 2006 4:39 am 
Newbie

Joined: Tue Oct 18, 2005 8:43 am
Posts: 15
hello,
I would like to make the following sql work with Hibernate, but can't seem to get it right...

Code:
select * from ge_outage_component where geo_id in (select geo_id from ge_outage_component group by geo_id having count(*)<2) order by geo_id


my GeOutageComponent class looks like this:

Code:
public class GeOutageComponent  implements java.io.Serializable {
     private Long id;
     private GeOutage geOutage;
     private Component component;
     // getters and setters...
}


and my hibernate-mapping:

Code:
<hibernate-mapping>
<class name="com.acme.ge.generated.GeOutageComponent" table="GE_OUTAGE_COMPONENT" lazy="false">
    <id name="id"  type="java.lang.Long" column="ID">
        <generator class="sequence">...</generator>
    </id>
    <many-to-one name="geOutage" class="com.acme.ge.generated.GeOutage" not-null="true">
        <column name="GEO_ID" />
    </many-to-one>
    <many-to-one name="component" class="com.acme.ge.generated.Component" not-null="true">
        <column name="CMP_IRN_NR" />
    </many-to-one>
</class>
</hibernate-mapping>


I've been struggling with this for a while now, but can't get it to work... Any help would be highly appreciated!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 5:31 am 
Newbie

Joined: Tue Oct 18, 2005 8:43 am
Posts: 15
this seems to do the trick, but the ordering doesn't seem to work...

Code:
from GeOutageComponent goc where goc.geOutage in (select gc.geOutage from GeOutageComponent gc group by gc.geOutage having count(*)<2) order by goc.geOutage


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