• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

JPQL Query and Native Query returning different results in spring-data-jpa

Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using in my project. I was trying to fetch records for last last week using annotation.


Native Query


Expected records should be 6 as I have records for 6 days in database.

JPQL Query is giving 6 records which is expected.
Native Query is giving 5 records, which is not correct.

But when I run the native query in my db tool, it fetches correct 6 records.
Using mysql as my database.

I am passing the value as '2018-05-22'. When I tried to debug native query is not fetching the records for 2018-05-22 even when I have condition as TRANS_DATE >= :date

Anyone have faced similar issue. What could be the possible reason.

Query printed by hibernate in both cases -

Native Query




Records in my database, fetched using sql query in my db tool.(First record is not coming when using Native Query)


Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!