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);
Example:
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)
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 accountCreatedTime? or can we get difference between Path accountCreatedTime and Path FirstPostCreatedTime in hours and in criteriaBuilder