ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Metsovuori Juho <Juho.Metsovu...@iltalehti.fi>
Subject Strange problem with resultMaps
Date Thu, 06 May 2010 10:27:40 GMT
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">

    <select id="getUser" parameterType="java.lang.String" resultType="User">
            SELECT * FROM <include refid="table"/> WHERE username = #{username}

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"
                     select="eventstream.model.mapper.UserMapper.getFriendsByUsername" />

    <select id="getFriendsByUsername"
            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)


To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message