I managed to get "the iBATIS way" working. Here are the changes if you're interested:
result property="roles" column="username" select="getUserRoles"/->
<result property="roles" resultMap="UserSQL.userRolesResult"/>
<resultMap id="userRolesResult" class="role">
<result property="id" column="ROLE_ID"/>
<result property="name" column="ROLE_NAME"/>
<result property="description" column="ROLE_DESCRIPTION"/>
Then change getUser/getUserByUsername to support a left outer join with the "role" table... my test SQL for getUserByUsername (which works) below:
<select id="getUserByUsername" resultMap="userResult">
select U.id, U.username, U.version, U.password, U.first_name, U.last_name , U.address, U.city, U.province, U.country, U.postal_code,
U.email, U.phone_number, U.website, U.password_hint, U.account_enabled, U.account_expired, U.account_locked, U.credentials_expired,
R.id as role_id, R.name as role_name, R.description as role_description
(app_user U left outer join user_role X
on U.id = X.user_id)
left outer join role R
on R.id = X.role_id
Then make sure you change:
<resultMap id="userResult" class="user">
<resultMap id="userResult" class="user" groupBy="id">
Finally, you can remove:
List roles = getSqlMapClientTemplate().queryForList("getUserRoles", user);
Don't know if this is any use to you. Thanks for your response.
On 9/7/06, Matt Raible <mraible@...> wrote:
On 9/7/06, Robert Campbell <rrc7cz@...> wrote:
> After a clean install of Appfuse (WebWork w/iBatis, multiple versions) we
> have this:
> <!--result property="roles" column="username"
> in the "UserSQL" iBatis sqlMap, specifically in the "userResult" resultMap.
> Why is this commented out. Instead of using this iBatis functionality (found
> on page 37 of
> this functionality was instead moved to UserDaoiBatis in the following code:
> List roles =
> user.setRoles(new HashSet(roles));
> where the user roles are manually added.
> I'm sure there is a good reason for doing it this way, I'm just curious as
> to what that reason is.
> Also, I tried to get the iBatis way of doing it to work, and was unable to
> get it working...
My reason is the same as yours - I couldn't get "the iBATIS way" to
work - so I did it manually.
> Sorry if this has already been answered, I couldn't find a reference to it
> in the mailing list.