-->
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: How to pass Criteria from UI to NH in business layer?
PostPosted: Tue Oct 04, 2005 4:47 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
OK, this is slightly off-topic, but would anyone have an good idea to share about how to implement a multi-criteria search screen powered by a CreateCriteria? :roll:

The question is basically: what is the best way to pass search criteria between presentation layer and NHibernate in a business layer? In a really flexible search with a complex object tree I feel like I'd need to bind my controls on the search screen and then to pass the whole set of Properties and their values as a Hashtable, so the Criteria would be build from it... It sounds a bit "hairy", esp. in cases where I have to nest calls to createCriteria() - so my UI controls would have to "know" nearly as much as hbm.xml files to pass all relationships properly. Hmmm... Am I missing something? Any pointers to right directions would be appreciated!

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 7:51 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
IMO, you should avoid doing something that is more complex than your needs. In my applications, I build a HQL query from the input of the users (in few controls)...
It depends of the level of complexity of your search system.

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 1:00 pm 
Newbie

Joined: Thu Sep 08, 2005 12:15 pm
Posts: 17
The way I do it is like this :

I have a search object in my BL and the search object have an array of search criterias(not NH crieria though).

In the UI, the user enter some values and then hit the search button. After that the UI layer create some crieria object and give them a type and a value
e.g: New Criteria(TypeCriteria.PersonFavoriteColor,HashTable values). Then I add the criterias to my search object.

After that I call a BL method named GetSearchResult(Search s). This method loop on all criteria of my serach object and build a HQL query based on the Type of the criteria. Then the result is return to my UI and then its rendered to the client.

Hope this help.
Simon


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 10, 2005 4:34 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Many thanks both of you!
I've got to the idea of a search object as well and was stubbornly trying to use Criteria API (that has a way higher geek factor) with it - but finally downscaled my ambitions to HQL...
Now a have a very nice universal search method that would search for anything provided UI builds a search object in respect of the domain model. 8) There are days I really like NHibernate - keep it up people!


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.