-->
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: DAO - Building Associations Query using Criterion..
PostPosted: Mon Jan 15, 2007 10:15 am 
Newbie

Joined: Fri Jan 05, 2007 6:44 am
Posts: 12
Hello

Using hib 3.1.2.

I am using the generic hiberante dao solution desc here: http://www.hibernate.org/328.html, but am having problems figuring out how to construct a sub query using the convenience method below:

Code:
/**
   * Use this inside subclasses as a convenience method.
   */
    @SuppressWarnings("unchecked")
    protected List<T> findByCriteria(Criterion... criterion) {
        Criteria crit = getSession().createCriteria(getPersistentClass());
        for (Criterion c : criterion) {
            crit.add(c);
        }
        return crit.list();
   }


The function takes a Criterion object, but from the API I cannot see out to use this obect to create an 'association query'.

Creating an association query seems straight forward using Criteria (docs 12.4) http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html, but this method accepts Criterion.

Question - using Criterion is it possible to query an association, if so how, if not then I'll simply change my design to accept a Criteria object instead.

regards

J.


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.