I'm starting with Spring Boot and I'm trying to use it for a query where I want to check if two date columns are between a given period of parameters. The code below works, however for this I have to repeat the parameters (start date and end date for comparison).
@Transactional(readOnly = true)
Collection<MyClass> findByDateBeginBetweenOrStartedWorkBetween (Instant firstDate, Instant lastDate, Instant firstDateAgain, Instant lastDateAgain);
I have not found any similar example so far. I figured it might look something like this:
@Transactional(readOnly = true)
Collection<MyClass> findByDateBeginOrStartedWorkBetween (Instant firstDate, Instant lastDate);
But when I compile the project, I get the error below:
Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.Collection with ... MyClass.findByDateBeginOrStartedWorkBetween (java.time.Instant, java.time.Instant)! No parameter available for part startedWork BETWEEN (2): [IsBetween, Between] NEVER.
Can I (and if so, how can I) use my comparison parameters only once using Spring Boot?