liveBook · Manning

Naming standard

As explained in Spring in Action, Sixth Edition

A naming convention is a prescribed pattern for names that allows software to infer structure or behavior from those names.

A naming standard prescribes patterns that let software infer structure or behavior from names. Spring Data applies this idea to repository methods: a Java method name can describe how data should be retrieved or stored. section 1.4.3

Spring Data recognizes comparison words embedded in method names, including LessThanEqual, Between, IsNull, IsIn, StartingWith, Containing, and IsNot. IgnoringCase handles string comparisons, while OrderBy adds sorting. section 3.3.4

Combining conditions and sorting

A method such as readOrdersByDeliveryZipAndPlacedAtBetween(String deliveryZip, Date startDate, Date endDate) combines a location condition with a date range. A method ending in OrderByDeliveryName sorts the results by delivery name.

Naming conventions work well for relatively simple queries, but long names become difficult to manage. Use @Query when a query is too complex or cannot be expressed clearly through the method name. section 3.3.4

The exact behavior depends on the persistence technology: JPA can infer queries from method names, whereas Spring Data JDBC requires @Query and SQL for custom query methods. section 3.3.4

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains recognized operators, case handling, sorting, and explicit queries, but defers complex queries to @Query.
Examples
Shows delivery-zip lookup, date-range filtering, case-insensitive matching, delivery-name sorting, and Seattle orders.
What it assumes
Assumes Java repository interfaces and distinguishes JPA query inference from JDBC SQL requirements.
What you can do after
Apply it via Spring Data by defining repository methods for simple queries and using @Query for complex ones.
How it connects
Connects Spring Data repositories with JPA, JDBC, method-name query derivation, and @Query.

Also explained in

Compare how 8 books explain naming standard →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.