tags:

views:

10

answers:

0

We are currently using Hibernate to fetch x number of objects out of the DB at a time for shoving into a ResultSet. Here is a sample code snippet:

    // create criteria
    Criteria criteria = GlobalState.createCriteria(HotlistRepository.class);
    criteria.createCriteria("owner").add(Restrictions.eq("displayName", user.getDisplayName()));

    ....

    // do sql
    criteria.setMaxResults(pgSize);
    criteria.setFirstResult(pgSize * (pgAt - 1));
    result.setCurrentResults(criteria.list());

No big deal. But, now I have within this class a Set of objects that I wish to do the same thing with. Any ideas? Here is my snippet from my db-full.xml:

    <!-- HotlistRepository -->
<class name="com...HotlistRepository" table="hotlist_repo">
    <id name="seq" node="seq" type="long" column="repo_seq">
        <generator class="sequence">
            <param name="sequence">hotlist_repo_seq</param>
        </generator>
    </id>
    <property name="name" column="repo_name" type="string" length="128" not-null="true"/>
    <property name="description" column="repo_desc" type="string" length="64"/>

    ....

    <set name="hotlistEntries" order-by="hot_tag asc" node="hotlistEntries" lazy="true">
        <key column="hot_repo_seq"/>
        <one-to-many class="com...HotlistEntry" node="HotlistEntry"/>
    </set>
</class>

<!-- HotlistEntry -->
<class name="com...HotlistEntry" table="hotlist_entry">
    <id name="seq" node="seq" type="long" column="hot_seq">
        <generator class="sequence">
            <param name="sequence">hotlist_entry_seq</param>
        </generator>
    </id>
    <property name="tag" node="tag" column="hot_tag" type="string" length="32"/>
    <property name="metadata" node="metadata" column="hot_meta" type="string" length="256"/>
</class>

Any help is greatly appreciated. Thanks, guys. Lance.