-->
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: Criteria select on criteria.list()
PostPosted: Fri Aug 22, 2014 5:13 pm 
Newbie

Joined: Fri Aug 22, 2014 4:21 pm
Posts: 1
Hi,

I have the following situation:

Code:
class A {}
class B {}

class C {
   has a class D;
   has a date;
}

class D {
   has a class A
   has a class B
}


I need to find all A's for a specific B on a specific date, that are related to C on that date.
So, my input is: B and date.
I need: A's that are related to C (by D) on the date.

My first step was:

Code:
Criteria critC = this.getSession().createCriteria(C.class);
        critC.add(Restrictions.eq("date", date));

        Criteria critD = critC.createCriteria("D");
        critD.add(Restrictions.eq("B", B));


And when i do a critC.list(), i have all my C's on that date and related to B.
Now i need to filter that list to return A's entity, and use a distinct (yes, i might have repeated A's).

Im not sure how to do that using criteria...im kinda new to hibernate, and after some research, i have no idea how to do that.

Any help??

Thanks in advance!


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.