java - How to limit a collection in an Object's property in hibernate? -
I have two entities: items, and quote, each item has several bids for it, so the collection of bid items Is the property.
On the item that appears on that page, I want to show the first 10 records of the bids about this "item".
Then, I query this:
but it will receive all the bids on one item, therefore, how about the restriction item bids?
This work is so good that you have items from bids.
Then you can select the item and apply the restriction restriction:
session .createQuery (select from b to b fetch b.item i where i. Id = 3 ") .setMaxResult (10) .list ();
By selecting your previous query, items and getting bids, all the items with all your bids will always be selected and the maximum-result will be in-range-memory applied. Because all children should always be in hibernation, this can not give you partial collection results.
Choosing a child and connecting with the parents is a better option. Restrictions apply to selected children without any restrictions.
Comments
Post a Comment