Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

Ranch Hand
Posts: 37
  • 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)


Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic