I want to fetch id from my table with count limit=1.
What I tried?
Optional<Long> findFirstIdByServiceSeeker_Id(Long serviceSeekerId); // But it returns Entity. I need id alone
I have following solution to fix it, but I want to know how to fetch id along with limit?
Alternate solution:
Optional<User> findFirstIdByServiceSeeker_Id(Long serviceSeekerId);
Optional<User> userOptional = userRepository.findFirstIdByServiceSeeker_Id(serviceSeekerId);
Long userId =userOptional.get().getId();// it will fix