I've been trying to get a n+1 example to work without much luck and I think
that I may have misunderstood the wiki article. I have intentionally kept
the example simple so I can fully understand the concepts and then apply it
to the real world app which uses the same principles.
I have three object tables
User, which has {user_id, name, type} columns
Group, which has {group_id, name, description} columns
Category, which has {cat_id, name, description} columns
I also have two relationship tables
UserGroup, which has {user_id, group_id} columns
UserCat, which has {user_id, group_id} columns
Each User can have multiple Groups and Categories. This is represented
through a User POJO which includes two Collection properties {groups,
categories} with appropriate setters and getters.
I currently use multiple SQL calls to populate the n+1 properties, I use a
<result property="groups" column="user_id" select="getUserGroups" /> and
the same for categories. You get the Idea. Ideally, I'd really like to use a
single SQL query to improve system performance.
Can I resolve multiple n+1 relationships in a single call and if so how. I'd
appreciate any help. I'm sure that once I get my head around the concept of
n+1 selects it will be easy.
Zoran