This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

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
  • 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();


 
Ranch Hand
Posts: 1871
12
  • Mark post as helpful
  • send pies
  • 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
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic