From the course: Spring Data

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Property expression query methods

Property expression query methods - Spring Tutorial

From the course: Spring Data

Property expression query methods

- [Instructor] So for general purpose database lookups, the built-in find all and find one repository methods are sufficient. But what should we do if we want to look up all full-time students or students with a certain last name or students with an age range? This chapter demonstrates how to use Spring Data comments to query the data source. Spring Data property expressions to the rescue. Via BeanUtils and reflection, Spring implements the method under the covers for us. However, we must follow the rules when declaring methods and correctly mapping the entity properties to the method signatures. So these are the rules when using property expressions to query for entities. First we have to declare the return type. For a single value it can be the actual class or an optional of it, for multiple, a collection. Then you need to begin the method signature with find by, followed by the property name in camel case. Optionally change sub property names following camel case rules. For…

Contents