Querieseasy0-2 years

A repository declares `List<User> findByEmaill(String email)` — a typo. When does that fail: at compile time, at startup, on the first call, or never? And at what point should a derived query method stop being a method name?

At startup. The name is valid Java, so the compiler cannot help, but Spring Data parses every derived query name when it builds the repository proxy, and it checks each property in the name against the entity. Emaill is not a property of User, so it throws a PropertyReferenceException and the application fails to start, naming the method. That is the right time to find out. The limit is readability, not the parser: once a name needs more than about three conditions, or any join, subquery, aggregate or optional filter, it should become a @Query or a Specification, because the parser will happily accept a method name nobody can review.

The lesson behind it →
More on Queries