Win a copy of TensorFlow 2.0 in Action 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Syntax error in Spring Data native query method?

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • 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: 22678
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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: 111
  • Mark post as helpful
  • send pies
  • 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 🙏
 
Master Rancher
Posts: 4710
49
  • Mark post as helpful
  • send pies
  • 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.
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic