-->
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.  [ 4 posts ] 
Author Message
 Post subject: Search Problem
PostPosted: Sat Apr 03, 2004 6:37 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:59 am
Posts: 47
Location: Gurgaon, India
Hello,

I am facing a problem while implementing searching for a many-many relationship. I am giving the scenerio:

I have a Document object and some of the categories. Any document can lie in one or more categories. So I made a separate table for categories and used a relation table between document and category, to implement many - 2 - many relationship between these two. So now, document object has a collection of categories.

Document -----0..* document_category*..0-----category

Now the requirement is, that I have to search document based on its categories type, which can be more than one.

This can be achieved in a way like:

We can get all the document from document_category table based on passed categories types using intersect clause.

So first I want to know that, can we use intersect clause in hibernateQL.

and second, is there any better approach for this scnerio .. means for searching documents based on its category collection parameters.

It is urgent, please reply asap.

_________________
Mohit Gupta
Software Engineer
Gurgaon, India


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 8:05 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Code:
select doc from Document doc, Category cat
where cat.a = :yourCriteria
and cat in elements (doc.cats)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 03, 2004 8:08 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:59 am
Posts: 47
Location: Gurgaon, India
Thanks delpouve,

This can work for me. I will try it.

_________________
Mohit Gupta
Software Engineer
Gurgaon, India


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 9:17 am 
Beginner
Beginner

Joined: Thu Feb 26, 2004 6:59 am
Posts: 47
Location: Gurgaon, India
Still I have a problem here. Actually based on criteria that I have for category object, I can get more than one object. Like requirement is like,

select document which contains categories having name a and b.

there is and condition required.

so how can I achieve this using HQL. As we can't apply both conditions on same object at the same time ie

select doc from Document doc, Category cat
where cat.a = myCriteria and cat.a = myCriteria1
and cat in elements (doc.cats)

---------------------

another method can be if I can check any of the property of list elements like

select doc from Document doc, Category cat
where myCriteria in (doc.categories).name &&
myCriteria1 in (doc.categories).name


Please suggest for it. It is very urgent.

Thanks

_________________
Mohit Gupta
Software Engineer
Gurgaon, India


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.