How to use MySQL functions with criteriaBuilder

199 Views Asked by At

I want get Specification<Entity>. I am use criteriaBuilder in my code. I have only start_date and duration. please refer table structure.

start_date | duration |
-----------|----------|
2022-06-07 |     10   |
2022-06-23 |      6   |

Please refer code example. I want to use. expireDate = start_date + duration

Specification<Entity> endDateSpec = (root, query, criteriaBuilder)->criteriaBuilder.equal(root.get("expireDate"), Date.valueOf('2022-06-07'));

please help me to write correct code according below code.

1

There are 1 best solutions below

1
Prodip Das On
start_date, duration, DATE_ADD(`start_date`, INTERVAL `duration` DAY)AS expireDate FROM tableName