Reputation:
For example, I have a big method name in Spring Data JPA interface.
Optional findByNameAndRestaurantIdAndDateAdded(String name, int restaurantId, LocalDate dateAdded);
If I add @Query, can I change it to something more readable?
@Query("SELECT d FROM Dish d " +
"WHERE d.name=?1 AND d.restaurant.id=?2 AND d.dateAdded=?3")
Optional<Dish> someRandomNameIWant(String name, int restaurantId, LocalDate dateAdded);
Does name of the method have any meaning when @Query is added?
Upvotes: 0
Views: 343
Reputation: 102
Yes, you can, as you defined your own query you do not use Spring Data's query derivation anymore
Upvotes: 2