I'm tring to write simple BBS system that has a few Forums, each forum has a number of posts associated to it, and each post could have a number of replies associated to it.
My hibernate mapping file looks like this (simplified):
Code:
<class name="org.ajiaojr.linnet.db.Forum" table="forum">
<id name="forumId" type="integer">
<column name="forum_id" />
<generator class="native" />
</id>
<list name="posts" lazy="true" batch-size="40" order-by="postDate asc">
<key>
<column name="forum_id" not-null="true" />
</key>
<one-to-many class="org.ajiaojr.linnet.db.Post" />
</list>
<list-index column="post_id" />
</class>
<class name="org.ajiaojr.linnet.db.Post" table="post">
<id name="postId" type="integer">
<column name="post_id" />
<generator class="native" />
</id>
<many-to-one name="rootPost" class="org.ajiaojr.linnet.db.Post" fetch="select" lazy="true">
<column name="root_post" not-null="true" />
</many-to-one>
<list name="replies" inverse="true" lazy="true" batch-size="40">
<key>
<column name="root_post" not-null="true" />
</key>
<one-to-many class="org.ajiaojr.linnet.db.Post" />
</list>
</class>
My question is that assume there are 2000 posts in a forum, it's natural that they should be splited into pages, if I were to access the 1500th - 1540th post, will the posts 1-1499 be fetched? If so, it'll mean a big performance impact, is there a way to avoid fetching those?
Thanks in advance.