编程语言
首页 > 编程语言> > java – 在Spring数据JPA中使用QueryByExampleExecutor接口的方法

java – 在Spring数据JPA中使用QueryByExampleExecutor接口的方法

作者:互联网

此接口的方法有什么用例QueryByExampleExecutor< T>在Spring数据JPA中.我用google搜索,只发现官方文档.

或许有人可以通过示例向我指出合适的资源.

特别是,该接口的findAll(示例< S>示例,Pagable可分页)是一种更简单的搜索,分页和排序方式吗?

解决方法:

来自Example的Spring Docs:

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.

因此,此类和QueryByExampleExecutor接口是Spring Data实现此Query By Example范例的一部分.

来自维基百科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.

最后,您引用的#findAll方法的文档说明如下:

<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.

所以QBE代表了一种使用更自然,基于模板的查询语法查询关系数据库的方法,而不是使用SQL,而Spring Data有一个支持它的API.

标签:java,spring,spring-data,spring-data-jpa,query-by-example
来源: https://codeday.me/bug/20190623/1267404.html