Forums Register Login

limiting collection result size

+Pie Number of slices to send: Send
Hi. I have a one-to-many relationship that I'm trying to build a query on, where I limit the number of rows returned in the collection, not in the entire result set. So for instance, where one dealership has many cars, I want a query that returns all dealerships and only 5 cars for each dealership. Can't get it to work, everything I try applies the "maxrows" to the entire result set.

Anyone have success with this or something similar?

Thanks in advance for your time and assistance...
+Pie Number of slices to send: Send
with SQL query I would make a view that joins both tables and

SELECT dealer,MAX(car) WHERE ........ GROUP BY dealer, not sure how would this map to your case...
+Pie Number of slices to send: Send
Is this question about a specific ORM tool. Or is it more a JDBC question, where this thread should be moved?

Mark
+Pie Number of slices to send: Send
Thanks for the reply. I'm actually trying to accomplish via Query by Example, or alternatively HQL.

At this point it looks like it's an explicit fetch against the collection (only), but it would be nice if I could do it in one query against the parent table.
+Pie Number of slices to send: Send
And

"Steve K"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Basically, you need to add your real last name.

Mark
Danger, 10,000 volts, very electic .... tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 612 times.
Similar Threads
Result Set size problem?
HQL: illegal attempt to dereference collection
one to many relations using ejb 2.x ?
Prepared statement null setting
Is this good approach to design DB i/f?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:03:40.