Grokking Spring Boot
Vote

0% completed

​

Spring Data Repositories

How can a method with no body run a database query?

The booking service declares SeatRepository as an interface. Nobody in the project writes a class that implements it. Yet a service that calls seats.findByEventIdAndLabel(eventId, "A12") receives seat A12. The log shows a correct SQL query with both conditions.

public interface SeatRepository extends JpaRepository<Seat, Long> { Optional<Seat> findByEventIdAndLabel(Long eventId, String label); long countByEventId(Long eventId); @Query(""" select s from Seat s where s.event

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content