From the Spring Docs for Example
:
Support for query by example (QBE). An Example takes a probe to define the example. Matching options and type safety can be tuned using ExampleMatcher.
So this class and the QueryByExampleExecutor
interface are part of Spring Data's implementation of this Query By Example paradigm.
From the Wikipedia post on Query by Example:
Query by Example (QBE) is a database query language for relational databases. It was devised by Moshé M. Zloof at IBM Research during the mid-1970s, in parallel to the development of SQL. It is the first graphical query language, using visual tables where the user would enter commands, example elements and conditions.
Finally, the documentation for the #findAll
method that you reference states the following:
<S extends T> Page<S> findAll(Example<S> example, Pageable pageable)
Returns a Page
of entities matching the given Example
. In case no match could be found, an empty Page
is returned.
So essentially QBE represents a way of querying a relational DB using a more natural, template-based querying syntax, as opposed to using SQL, and Spring Data has an API which supports that.
Example.of(person)
and not person tofindAll()
. Can you please explain the reason of existence ofExamples
andExampleMatcher
? – Whimper