Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

How to skip @Param in @Query if is null or empty in Spring Data JPA

Try changing

" and ds.statusCode in :paymentStatuses"

into

" and (:paymentStatuses is null or ds.statusCode in :paymentStatuses)"

Try changing

" and ds.statusCode in :paymentStatuses"

into

" and (COALESCE(:paymentStatuses, null) is null or ds.statusCode in :paymentStatuses)"

This solution will work for the empty list, null list, and a list with items 1 or more.

Tags:

Java

Hibernate

Spring

Jpql

Spring Data Jpa

Related

Error in bind_rows_(x, .id) : Column can't be converted from factor to numeric Installing a .NetStandard 2.0 Nuget package into a VS2015 Net 4.6.1 project What `native overlay diff` mean in overlay2 storage driver? stringr str_extract capture group capturing everything How and where to use ::ng-deep? Angular matSort does not sort How to know region size used of G1 garbage collector? Running composer install within a Dockerfile Why bubble sort is faster than quick sort Counting the Frequency of words in a pandas data frame Laravel Composer sees wrong PHP Version iisexpress.exe started crashing with Access Violation in IsLocalRequest call

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy