Hello everyone
I'm coding with mybatis annotation and spring boot
I'm getting this error message :
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value
For me it's normal, because the query return nothing, (there are no data yet)
the first mapper use the second mapper to get data. As I explain, the second mapper is returning nothing because there are no data yet, and it's normal.
First mapper code:
@Mapper
public interface UsersRepositoryMapper {
@Select("SELECT * FROM tb_users WHERE id_public_user = #{userId}")
@Results(id = "userResultMap", value = {
@Result(property = "languages", column = "id",
one = @One(select = "com.app.ws.repository.mapper.CountriesRepositoryMapper.findLanguagesByIdUsers"))
})
UserEntity findUserDetailsByUserId(@Param("userId") String userId);
}
Second mapper code:
@Mapper
public interface CountriesRepositoryMapper {
@Select("SELECT GROUP_CONCAT(C.language SEPARATOR ', ') AS languages FROM tb_countries C"
+ " JOIN tb_languages L ON C.id = L.id_countries"
+ " JOIN tb_users U ON L.id_users = U.id"
+ " WHERE U.id = #{id}"
+ " GROUP BY 'all'")
public String findLanguagesByIdUsers(@Param("id") String id);
}
So I don't understand why I get the error message. I should have null in languages property that is a string in userEntity class.
Thanks for your help