-->
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: Implementing Multi Search Criteria with multiple table
PostPosted: Wed Jun 21, 2006 4:51 pm 
Newbie

Joined: Wed Jun 21, 2006 4:38 pm
Posts: 1
Location: Dallas
Hi

I am working on a module, part of which is implementing search functionality. To walk you guys thru,

I have 4 text boxes and 3 drop down lists in the screen. The user can enter either 1 or more search criteria (criteria here is the data the user enters into the text boxes or the drop down list). I have to use the Hibernate Criteria to implement this. The resulting data of the search comes from different tables in the database(Oracle 9i).

I am able to retrieve values from a single table using the criteria object. Part of the code is:

1. creatCriteria(BO.class) ... BO here is a class with getter/setters of the table fields and some business logic(methods to search/update etc.)
.
.
2. hibCriteria.add(Expression.eq("id", getter)

3.criteria.list()

Can you guys tell me how i can get results from different tables(3 different tables, to be specific, this doesnt matter though).

Replies would be appreciated.

Thanks.

Arshad.

_________________
When the goin gets tough, the tough get goin.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 21, 2006 10:05 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Tables are "unimportant", it's mapped classes that are relevant for criteria. All returned values must be derivable from a single class: any number of mapped associations/collections may be navigated, and values from any of those assoicated entities may result from the criteria, but the important point is that a single mapped class is the root of the query.

Smart use of subqueries can bend this rule a bit.

If the tables you are searching on are not mapped to classes, then criteria cannot help you. Use SQL queries.

_________________
Code tags are your friend. Know them and use them.


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.