使用my-batis将返回类型转换为boolean?

rog*_*rgl 3 mybatis spring-mybatis

我目前正在使用以下映射:

@Select ("select count(*) from something where id = 2344")
int userExists();
Run Code Online (Sandbox Code Playgroud)

但我希望有类似的东西:

@Select ("select count(*) from something where id = 2344")
boolean userExists();
Run Code Online (Sandbox Code Playgroud)

我可以将0转换为false并将所有内容> 0转换为true吗?

我正在使用Oracle.因此,我希望my-batis提供某种返回类型映射.

Ian*_*Lim 6

以下是通过在Oracle中使用case语句在Oracle中返回布尔值的方法:

@Select ("select case when count(*) > 0 then 1 else 0 end result from something where id = 2344")
boolean userExists();
Run Code Online (Sandbox Code Playgroud)

希望它对你有所帮助.