-->
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: using criteria in subqueries
PostPosted: Fri Mar 19, 2004 12:35 pm 
Newbie

Joined: Fri Mar 19, 2004 11:39 am
Posts: 4
Hello,

I would like to use hibernate as an persistence layer of my Forum. I use the Criterions and Criterias to build queries, but i don't know, how can I make a subquery with these components.

I would like change the following section with using criterions

Code:
try {
    Session sess = HibernateSession.currentSession();
    String querystring = "from Usr as usr where usr.usrloginname in ( " +
                                    " select distinct message.usr.usrloginname from Message as message where " +
                                    " message.creationdate between :startdate and :enddate ) ";
    Query q = sess.createQuery(querystring);
    Date startdate = new GregorianCalendar(2003, 2, 18).getTime();
    Date enddate = new GregorianCalendar(2003, 2, 29).getTime();
    q.setParameter("startdate", startdate);
    q.setParameter("enddate", enddate);
    Iterator it = q.iterate();
    while (it.hasNext()) {
        Usr usr = (Usr)it.next();
        log.info(usr.getUsrloginname());
    }
} catch (Exception e) {
    log.error(e);   
} finally {
    try {
        HibernateSession.closeSession();
    } catch (Exception e) {
        log.error(e);
    }
}


Thx,

Kincza


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 2:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Not possible yet. Only thing you could do would be splitting the query in two.


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.