• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

How to translate sql query to spring boot query with when case and two left join terms?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to translate sql query to spring boot query?

select  ru.id, ru.name,
case when a.r_id is null
then false
else true
end as acc
from ru
left join  a
on ru.id  = a.r_id  and a.a_id = 1
left join b
on b.id  = a.a_id



it doesn't work in this, where is problem:
@Query("select  ru.id, ru.name,
case when a.r_id is null
then false
else true
end as acc
from ru
left join  a
on ru.id  = a.r_id  and a.a_id = 1
left join b
on b.id  = a.a_id")
List<ExamplesDto> getExamples();


 
Bartender
Posts: 2072
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about @Query("select ru.id , ru.name, case when ..... ", nativeQuery=true) ?

Reference:
https://www.baeldung.com/spring-data-jpa-query
 
Let's go to the waterfront with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic