-->
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 for many-to-one
PostPosted: Fri Jun 30, 2006 1:25 pm 
Newbie

Joined: Wed Feb 25, 2004 7:20 pm
Posts: 4
Hi,

I might miss something obvious here, but i cant seem to find any information regarding this in "hibernate in action" or in forums..

here goes..

I have the following 4 tables:

USER:
NAME

SUBSCRIBER:
FK_USER
ADDRESS

NOTIFIER:
FK_USER
ADDRESS

SUBSCRIPTION:
FK_SUBSCRIBER
FK_NOTIFIER
TYPE

I want to make _one_ query (with the Criteria API) for subscriptions.. the query should find all subscriptions that matches a certain subscription type and a specific name for both the subscriber and notifier.. all associations are modeled as many-to-one.. (subscription->subscriber, subscription->notifier, subscriber->user, notifier->user)

How to do this? I start out with:
Code:
Criteria subscriber = session.createCriteria(Subscription.class)add(Expression.like("type", someType).createCriteria("subscriber");
subscriber.createCriteria("user").add(Expression.like("name", someName);


but here im stuck.. how can i "navigate" back to Subscription to grab the notifier and make a similar criteria which is added to the total criteria?

Im using hibernate 2.1.3..

all help is appreciated!

Thanks,
-Kristoffer

[/u]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 30, 2006 5:23 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Tried using HQL?


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.