-->
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 search two tables?
PostPosted: Sun Oct 10, 2004 6:09 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Hi everyone:


I want to add a search function to my web application. I use hibernate paging interface . But the hibernate doc show how to search one table using
Code:
  setMaxResult(); setFirstResult();
But the problem is that if I want to search two tables what will return ? I means that If I search one table it will return a POJO object,but if two tables? For example: HSQL:
Code:
from Article a Author au where a.title='book' and au.name='yashnoo'
what will return ?

I don't know what object it will return. Please help me.

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 10, 2004 8:10 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
It will return a List containing Object[]. Each Object[], Object[ 0 ] will be the article and Object[ 1 ] the author.


Top
 Profile  
 
 Post subject: :(
PostPosted: Mon Oct 11, 2004 11:12 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Thks Myk.

But if I want to paging the result,how to do it? I mean that could hibernate limit the result count if I query several tables?

For example: like this query:

Code:
select g.groupname, r.roleid, u.username from Group g,Role r , User u where g.groupid=1 and r.role_description='good'.


You will find that it is difficult to paging. If I query one table ,I can paging like this:
Code:
Query q=session.createQuery("from Group");
setMaxResult(..);
setFirstResult(..);


But if more than one tables:
Code:
Query q=session.createQuery("select g.groupname, r.roleid, u.username from Group g,Role r , User u where g.groupid=1 and r.role_description='good'.");
setMaxResult(..);
setFirstResult(..);


What will return ? If it return a List, what will I get in this List?
Help!

_________________
You are not alone...


Top
 Profile  
 
 Post subject: :(
PostPosted: Tue Oct 12, 2004 7:30 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Any idea?

_________________
You are not alone...


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.