Everyone reading this book should be familiar with SQL queries and how they work. Constructing a simple query against the ttt_company
table to retrieve all records would look something like:
select * from ttt_company
Restricting the result set to companies starting with G
would look like the following code line:
select * from ttt_company where company_name like "G%"
In JPA, we are dealing with entities and relationships between entities. The Java Persistence Query Language (JPQL) is used to formulate queries in a similar way to SQL. The previously mentioned statement will be written in JPQL as follows:
SELECT c FROM Company c
And the statement that follows is written as such:
SELECT c FROM Company c WHERE c.companyName LIKE 'G%'
The following are the major differences between SQL and JPQL:
JPQL class and field names are case sensitive. When we are dealing with classes, the class name must start with an uppercase letter. All the fields must have the...