-->
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: O\R Mapping general questions
PostPosted: Mon Mar 12, 2012 11:26 pm 
Newbie

Joined: Mon Jul 25, 2011 12:30 pm
Posts: 2
Ok. So, here it goes. I have an Object graph kind of like below (note that this is just an example):

Company (Entity)
-id
-name
-Site (one-to-many)
--id
--name
--Address
--- id, line1, line2, city, state, zip, countrySubdivision, country, phoneNumber
-Products (one-to-many, could be up to 100k)
--id, name, sku, upc, unitPrice, percentDiscount, rebates, image(blob), notes etc..
-status
-createdBy
-recordCreationDate
-lastUpdateDate
- updatedBy
...

The problem is I would like to fetch companies as per certain input search criteria, but I don't want to fetch all the products, I only want 1000 at a time, basically pagination. I have two grids, one for the header result search and another for the products. The requirement is to display partial product results and have the user\customer refine their search or they may choose to paginate.

Is there any way to enable pagination for an inner object in the graph, without breaking the graph or trying to flatten it.

I can always break it into two separate queries, which is what I was planning to do in any case, didn't know if there was a more elegant solution. i.e. some way to limit children of a parent if there are too many - this is to prevent loading too many objects in memory.

Thanks!


Top
 Profile  
 
 Post subject: Re: O\R Mapping general questions
PostPosted: Tue Mar 13, 2012 3:32 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Pagination in Hibernate is done by using following 2 methods

Code:
query.setFirstResult(int pos)
query.setMaxResults(int num)


where 'query' can be a HQL, Criteria, JPA-QL or Native-SQL query object.
But if pagination works depends on the capabilities of the database and jdbc-driver you are using.
Several databases/jdbc-driver's do not.


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.