Mapped Statements collection does not contain value

1,415 views
Skip to first unread message

jdeo...@gmail.com

unread,
Aug 19, 2021, 12:38:53 PM8/19/21
to mybatis-user
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)

sql.JPG


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

jdeo...@gmail.com

unread,
Aug 20, 2021, 3:40:29 AM8/20/21
to mybatis-user
Oki I found out

I was missing one character from the link to the mapper

Sorry for this post

Guy Rouillier

unread,
Aug 20, 2021, 3:45:37 AM8/20/21
to mybatis-user
I believe this error is not referring to the data the statements are retrieving.  Instead, the error is with MyBatis being unable to locate the statements themselves.  This is usually a classpath problem.  You can easily confirm this by commenting out the chained SQL.  If the error goes away, then you know MyBatis is unable to find the chained statement.

--
Guy Rouillier
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatis-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/2c46d61b-17fb-430b-b0b1-f726a59cb934n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages