Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

129
Views
Spring @Query with Lower and Wildcards

This Question refers to Spring Data JPA.

I need a (native) @Query with the Lower Function and Wildcards. But I dont get it to work.

Here is a oversimplified version of what I am looking for:

@Query(value = "SELECT * FROM CAR c WHERE LOWER(c.model) LIKE LOWER(%:model%)", nativeQuery = true)
List<Car> findByModelMatching( @Param("model") String model );

LOWER(%:model%) -> not working! LOWER(:model) -> works!

I am aware of that such a query can be easily re-written as:

List<Car> findByModelContainingIgnoreCase( String model );

But I am not looking for a Named Query.

My Question is: How to combine LOWER (or even UPPER) with WildCards in a @Query!

Cheers

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The LOWER function accepts strings, you should write LOWER('%' || :model || '%') if you are on Oracle for example.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!