session.createSQLQuery("SELECT EXISTS
(SELECT 1 FROM master.invoices WHERE currency_id = 17879)").list()
给了我BigInteger。 我怎样才能获得布尔值?
答案 0 :(得分:1)
相应地尝试这个dude
SELECT CASE WHEN EXISTS(
SELECT *
FROM
master.invoices
WHERE currency_id = 17879
)
THEN CAST(1 AS BIT)
ELSE CAST(0 AS BIT) END
答案 1 :(得分:1)
以下是它的工作原理。
Boolean.valueOf((List<String>) session.createSQLQuery("SELECT IF
(SELECT 1 FROM master.invoices WHERE currency_id = 17879)
, 'true', 'false')").list());