-->
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: Paging a collection
PostPosted: Fri Aug 15, 2008 12:23 pm 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
Hi,

I am a newbie to Hibernate.

I searched for paging in this forum and came with a lot of hits, sorry if this has been answered already.

In my Seam page, I display a list of records from a table called Tax which has a One-To-Many with a table called Item

So in my Tax entity class, I have
Code:
   
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tax")
   public Set<Item> getItems() {
      return this.items;
   }


On my Tax list page, I use a EntityQuery backed list with paging controls which use firstResult parameter to limit the rows.

When I click a tax on the list page, I now display a list of associated items.
So Hibernate will fire the query getItems() above.

My problem is how do I limit rows returned from getItems() and having paging controls for it. I can't do setFirstResult() and setMaxResults() ?

thanks for any guidance.

Regards
Franco


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 15, 2008 1:57 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Check out if the Session.createFilter() may help you. It seems like it returns a Query object that is applied to a collection. Here is a link to some examples:
http://www.hibernate.org/hib_docs/v3/re ... -filtering


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 16, 2008 7:01 am 
Newbie

Joined: Fri Aug 17, 2007 2:11 pm
Posts: 19
Thanks.

I had to make a call to getItems() from my EntityHome object in Seam, after plugging in a createFilter, it seems like getItems() gets called for as many rows that I have in the relation.

Sorry, can't post the code - using my home laptop now.

I think it will work, just have to play with it a little bit more.

Franco


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.