JPA JPQL Bulk Data Operations
In the previous section, we fetched single column only. Now, we will learn how to handle bulk data and perform corresponding operations.
JPQL Bulk Data Example
In this example, we will take a basic entity class (in this case StudentEntity.java) and perform different operations on it.
- Create an entity class named as StudentEntity.java under com.tutoraspire.jpa package.
StudentEntity.java
- Now, map the entity class and other databases confiuguration in Persistence.xml file.
Persistence.xml
- Now, we can perform any of the following operations on StudentEntity.java class.
JPQL Fetch
Here, we will fetch all the records from the database.
FetchData.java
Output:
JPQL Update
Here, we will update the records in database.
UpdateData.java
Output:
After the execution of the program, the following student table generates under MySQL workbench. To fetch data, run select * from student in MySQL.
JPQL Delete
Here, we will delete the particular records from database.
DeleteData.java
Output:
After the execution of the program, the following student table generates under MySQL workbench. To fetch data, run select * from student in MySQL.