• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

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: 2265
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
reply
    Bookmark Topic Watch Topic
  • New Topic