No its impossible
Java does not allow you to define two functions with the same prototype. U may instead have a selector that calls functions based on some environment variable
public interface TransactionRepository extends JpaRepository<Transaction, String>, QueryDslPredicateExecutor<Transaction> { @Lock(LockModeType.PESSIMISTIC_WRITE) Transaction findOne_withLock(Predicate p); default Transaction findOne(Predicate p) { if (EvironmentCheck) { return findOne_withLock(p); } return findOne(p); } }
source share