Hey all,
I have a this strange problem with resultMaps. When I use the query below to
retrieve a users information, everything works great.
public class User
private int id = 0;
private String username = "";
private String password = "";
private Timestamp registeredAt;
private Timestamp lastLogin;
private List<User> friends = new ArrayList<User>();
<sql id="table">
users
</sql>
<select id="getUser" parameterType="java.lang.String" resultType="User">
SELECT * FROM <include refid="table"/> WHERE username = #{username}
</select>
But I need to add a resultMap, see below, to retrieve all the users friends.
When I use this resultMap, I don't get any of the users friends or even the
users own username, but I DO get the users password and other info. So do you
have any ideas why this doesn't work, and why I don't get the users username.
The actualy sql queries do work, I tested them manually.
<resultMap id="friendByUsernameMap" type="User">
<association property="friends"
column="username"
javaType="java.util.ArrayList"
select="eventstream.model.mapper.UserMapper.getFriendsByUsername" />
</resultMap>
<select id="getFriendsByUsername"
parameterType="java.lang.String"
resultType="User">
SELECT * FROM <include refid="table"/>
WHERE id IN
(SELECT userFriendId
FROM users_to_users, users
WHERE users.username = #{username}
AND users_to_users.userId = users.id)
</select>
Thanks
Juho
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]