-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query based on various inputs
PostPosted: Tue Mar 20, 2007 11:08 am 
Newbie

Joined: Tue Mar 20, 2007 10:55 am
Posts: 3
Hi all,

I have a basically simple question, which seems to be hard to track down. I tried to search but actually I'm not even sure what I search ;)

What I've done: So far I installed Hibernate, created the config and the mappings and did some first testing (inserting data). This all worked very well. Now I wanted to load some data and got stuck.

I have a class called "Person" with variables like name, surname, city etc. I now want to present a search form to the user in which he can fill in the name and/or surname and/or city to search.

What would work is to create a Query string based on the input with "if" clauses. But somehow I think there has to be a better way. What I would love to do is to create an instance of the Person class, then fill in the variables I have (based on the UI) and then call a single method do load the data, based on the variables of the instance.

In an ERP System I use I can do that with "select choose", but I didn't find something similar in HQL. I also tried a criteria, which basically worked. But when I tried to not enter all data, it got no result.

I looked into criterias, filters and collections, but got confused. Maybe if only someone could point me into the right directions (e.g. "use collections!"), I might find the solution faster...

thanks in advance

Ellegon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 11:25 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Use Example queries!

http://www.hibernate.org/hib_docs/v3/re ... a-examples


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 8:53 am 
Newbie

Joined: Tue Mar 20, 2007 10:55 am
Posts: 3
Ananasi wrote:


Wow, thanks a lot. I knew there has to be a simple way, but I felt like searching for trees in a forest ;)

It worked like a charm... ;)


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