Basic Tutorial
Queries
JPQL (Java Persistence Query Language) is a Hibernate-based query language used to retrieve data from the database in Spring Data JPA. It is similar to SQL but operates on entity objects instead of database tables.
Let's assume we have a User
entity with fields: id
, name
, email
and age
.
Table name : user
id | name | age | |
---|---|---|---|
1 | John | john@gmail.com | 25 |
2 | Mike | mike@gmail.com | 35 |
3 | Watson | watson@gmail.com | 40 |
4 | Kenny | kenny@gmail.com | 45 |
findAllUsers , findByName , findUsersOlderThan optional queries you don't want to write Jpa write query for you
Once the application is running, test the endpoints:
GET:http://localhost:8080/users
GET:http://localhost:8080/users/{userName}
GET:http://localhost:8080/users/older/{age}
PUT:http://localhost:8080/users/{userID}/email
DELETE:http://localhost:8080/users/{userID}