Well I fixed it. Not sure if its the best way or not but I'll share just in case it can help someone else. Bummer nobody responded at all to my post... not even to ask for more info. Any way here goes:
I put teamGroups in the teams class / mapping:
Code:
<set name="teamGroups" table="team_group_teams">
<key column="team_id"/>
<many-to-many class="com.ack.dreamjournal.bo.TeamGroup" column="team_group_id" />
</set>
Now I do a criteria query on the teams class instead of the
teamGroups class so the setMaxResults will limit what I want.
Code:
Criteria c = this.getSession().createCriteria( Team.class);
c.createAlias("teamGroups", "dg");
c.add(Restrictions.eq("dg.id", dg.getId() ));
c.setFirstResult( startPage * teamsPerPage);
c.setMaxResults(teamsPerPage);
The createAlias is needed so hibernate will join correctly.
It took 30 seconds to write the sql query to give me the results, and
about 5 hours in all to figure out how to make hibernate do it.
Ugh...