mybatis用动态SQL<foreach>报错

代码:

<!--根据角色id查询所拥有的菜单信息 public List<Menu> findParentMenuByRoleId(List<Integer> ids);-->
    <select id="findParentMenuByRoleId" parameterType="java.util.List" resultType="com.lagou.domain.Menu">
        SELECT
        DISTINCT m.*
        FROM roles r INNER JOIN role_menu_relation rm ON r.`id` = rm.role_id
        INNER JOIN menu m ON rm.menu_id = m.id
        WHERE m.parent_id = -1 AND r.id IN
        <foreach collection="list" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        GROUP BY m.id
    </select>

报错信息:
21:30:46,742 DEBUG findParentMenuByRoleId:143 - ==> Preparing: SELECT DISTINCT m.* FROM roles r INNER JOIN role_menu_relation rm ON r.id = rm.role_id INNER JOIN menu m ON rm.menu_id = m.id WHERE m.parent_id = -1 AND r.id IN GROUP BY m.id
21:30:46,743 DEBUG findParentMenuByRoleId:143 - ==> Parameters:
21:30:46,745 DEBUG SqlSessionUtils:191 - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16b5d491]
21:30:46,745 DEBUG SQLErrorCodeSQLExceptionTranslator:402 - Translating SQLException with SQL state '42000', error code '1064', message [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7] for task [

Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7

The error may exist in com/lagou/dao/UserMapper.xml

The error may involve com.lagou.dao.UserMapper.findParentMenuByRoleId-Inline

The error occurred while setting parameters

SQL: SELECT DISTINCT m.* FROM roles r INNER JOIN role_menu_relation rm ON r.id = rm.role_id INNER JOIN menu m ON rm.menu_id = m.id WHERE m.parent_id = -1 AND r.id IN GROUP BY m.id

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7

]
21:30:46,746 DEBUG DispatcherServlet:1100 - Failed to complete request: org.springframework.jdbc.BadSqlGrammarException:

Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7

The error may exist in com/lagou/dao/UserMapper.xml

The error may involve com.lagou.dao.UserMapper.findParentMenuByRoleId-Inline

The error occurred while setting parameters

SQL: SELECT DISTINCT m.* FROM roles r INNER JOIN role_menu_relation rm ON r.id = rm.role_id INNER JOIN menu m ON rm.menu_id = m.id WHERE m.parent_id = -1 AND r.id IN GROUP BY m.id

Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY m.id' at line 7

少了index?

<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
    #{item}
</foreach>

查询条件select中查了m.* ,但是后面是根据group by id来的,把group by id 去掉