• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Criteria builder and Path..How to compare dates column

Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi Sir,

I have a doubt in jpa query criteria builder with path or expression.

//I want to find who are all entered first post comment with in an hour after their  account created
       Path<Date> accountCreatedTime = root.<Date> get("AccountCreatedTime");
Path<Date> FirstPostCreatedTime = root.<Date> get("FirstPostCreatedTime");

       final Predicate timeInHourPredicate = criteriaBuilder
               .greaterThanOrEqualTo(accountCreatedTime, FirstPostCreatedTime);
1. Account Created at: 2018-SEP-10 at 10am and First Post entered 2018-SEP-10 at 10.15 am  this recond should be fetched. (FALLS IN AN HOUR)
2. Account Created at: 2018-SEP-10 at 10am and First Post entered 2018-SEP-10 at 3.50 pm  this SHOULD NOT  be fetched.

Is there any  way to add or separate hours from Path<Date> accountCreatedTime? or can we get difference between   Path<Date> accountCreatedTime  and Path<Date> FirstPostCreatedTime  in hours and in criteriaBuilder
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic