-->
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: Criteria + record count of Subquery
PostPosted: Thu Mar 22, 2007 10:11 pm 
Newbie

Joined: Thu Mar 22, 2007 9:54 pm
Posts: 1
I would like to get the record count of subquery by the following SQL:

Code:
select
    count(*) as total
    from (
        select
            pf.source,
            pf.sourcePort,
            pf.action,
            pf.target,
            pf.targetPort,
            pf.protocol,
            count(pf.source)
        from
            PackageFilter pf
        where
            pf.idServer=1
        and (
            pf.source like '150.163.140.112%' or pf.target like '150.163.140.112%'
        ) and
            pf.date between '2007-03-10' and '2007-03-15'
        group by
            pf.source,
            pf.action,
            pf.target,
            pf.targetPort
    ) as mySubquery;


i know that Hibernate doesn't support subqueries in the FROM clause, but how can i do this to use Criteria?

Thanks a lot!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2007 10:17 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I don't understand what you want: Hibernate can't do select in the from clause, you're right, so why do you say:
Quote:
but how can i do this to use Criteria?

I guess that if you really need this query, maybe first try to isolate it in an external named query using pure SQL. Your code doesn't even need to know it's using HQL, SQL, or whatever. This way, maybe you'll be able to convert it into another query when Hibernate will eventually support select in from clause (if it ever happens :)).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.