This is a usage pattern problem rather than a hibernate problem.
I have a user class and a log class, each mapped to a table. Every user action will generate a log record. Thus a user object might associate with many log records.
While the number of records might be huge, every time I only need the most recent 100 rows. But per my understanding, in a mapped one-to-many association, once the List is fetched(be it lazy or not), all the records are fetched from database. Am I right?
Is it a good implementation to associate the User class with Record class with a one-to-many association? Or should I merely use joined query to fetch first 100 rows of records?
Thanks!
|