JPA query 基本语法解释

JPA query 基本语法解释

JPA query 基本语法解释

详细语法官网去学习 -->> http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#reference

                              摘抄2018.02.19版本: [http://www.cnblogs.com/wangdaijun/p/8482073.html](http://www.cnblogs.com/wangdaijun/p/8482073.html)

Query creation

Generally the query creation mechanism for JPA works as described in Query methods. Here’s a short example of what a JPA query method translates into:

Example 43. Query creation from method names

public interface UserRepository extends Repository { List findByEmailAddressAndLastname(String emailAddress, String lastname); }

We will create a query using the JPA criteria API from this but essentially this translates into the following query:select u from User u where u.emailAddress = ?1 and u.lastname = ?2. Spring Data JPA will do a property check and traverse nested properties as described in Property expressions. Here’s an overview of the keywords supported for JPA and what a method containing that keyword essentially translates to.

你可能感兴趣的:(JPA query 基本语法解释)