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

时间:2015-09-23 07:27:08

标签: mybatis spring-mybatis

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

@Select ("select count(*) from something where id = 2344")
int userExists();

但我希望有类似的东西:

@Select ("select count(*) from something where id = 2344")
boolean userExists();

我可以将0转换为false而且所有内容都是> 0到真?

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

1 个答案:

答案 0 :(得分:6)

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

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

希望它对你有所帮助。