JPQL statement returning boolean value

后端 未结 3 2056
北海茫月
北海茫月 2020-12-29 18:24

Is it possible to write JPQL query like following:

select count(*) > 0 from Scenario scen where scen.name = :name

that would return true/fals

相关标签:
3条回答
  • 2020-12-29 19:03

    What about just:

    select count(scen) > 0
    from Scenario scen where scen.name = :name
    
    0 讨论(0)
  • 2020-12-29 19:11

    I was having the same problem, then I updated my hibernate to 4.3.11.Final and now it's working.

    0 讨论(0)
  • 2020-12-29 19:12

    Yes, it is possible with following:

    select case when (count(scen) > 0)  then true else false end  
    from Scenario scen where scen.name = :name
    
    0 讨论(0)
提交回复
热议问题