• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Syntax error in Spring Data native query method?

 
Ranch Hand
Posts: 149
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this method in JpaRepository interface:




I make sure I'm not passing nulls. Im just passing empty or non-empty strings.

This is my query which referenced by findInvoices:



I'm getting:



I've also tried writing symptomatic part in the query like this:



No luck.

I was able to make this (a bit modified) query work in MySQL Workbench. Any suggestions?
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My first question is why is that a native (SQL) query instead of a JPA (JPQL) query? I don't see anything special about it. Seems to be making things needlessly complicated.
 
Mike Gosling
Ranch Hand
Posts: 149
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to be honest I'm not yet confident enough to use Jpql. that's why Im using plain sql..But as you see..I need to generate some custom DTO, so using SqlMapper (Im not aure about annotation's name) is more convenient for me in this case. Hope anyone can help me with this 🙏
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a LIKE doesn't the '%' markers need to be part of the string being bound in, and not part of the query?
That looks wrong from here.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic