-->
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: Do I need to use association?
PostPosted: Sat Nov 13, 2004 12:11 pm 
Newbie

Joined: Tue Nov 09, 2004 9:49 pm
Posts: 1
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!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 13, 2004 3:05 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
checl the "where" attribute to get 100 lasts.
also use a bag to avoid fetching when you insert a new log.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.